Adding 'where' in Entity Framework query didn't work? -


        erpentities dbentities = new erpentities();         var clscode = "001";         var items = dbentities.clsitem.select(aa => aa);         if (clscode != null)             items.where(aa => aa.clscode == clscode);         var _test = items.tolist(); 

there 21 rows in table clsitem.

after executing, result of _test.count() 21 (which means item.where()) didn't work.

but if use var _test = dbentities.clsitem.where(aa => aa.clscode == clscode);, i'll expecte.

why ?

how can filtered data if need have if expression see wheather clscode not null before executing query? (i don't want whole data in database)

you not result of items. where not change source collection. method returns new collection.

    erpentities dbentities = new erpentities();     var clscode = "001";     var items = dbentities.clsitem.select(aa => aa);     if (clscode != null)         items = items.where(aa => aa.clscode == clscode); // string     var _test = items.tolist(); 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -