sql server - Invalid Object Name, Temporary Table Entity Framework -


i´m trying optimize process in application i´m stuck problem. application working entity mapping correct. simplifying i´m trying this:

using (var offctx = new checkinofflineentities()) {     using (var trans = offctx.database.begintransaction(isolationlevel.snapshot))     {          datetime purgepivot = datetime.now.adddays(-2);          count = offctx.database.executesqlcommand(@"select l.* #newlegs inventoryleg l l.stdutc >= {0}", purgepivot);          long d = offctx.database.sqlquery<long>("select count(*) #newlegs").firstordefault();     } } 

i´m selecting data want delete 1 table, storing in temporary table can use temporary table in other queries exclude related data.

the problem is, when try use temporary table i´m receiving exception sqlexception: "invalid object name '#newlegs'."

thank time.

you can merge query this.

and count returns int, not long.

count returns int data type value. - msdn

var query = string.format("{0} {1}",     @"select l.* #newlegs inventoryleg l l.stdutc >= @stdutc",     @"select count(*) #newlegs") var d = offctx.database.sqlquery<int>(query, new sqlparameter("stdutc", purgepivot))     .firstordefault(); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -