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
Post a Comment