.net - OrderBy, GetNewBindingList and Linq to SQL -
i have background worker performs loading of data database temporary structure.
data d = new data(); d.listgroup = context.groups.getnewbindinglist(); d.tbuser = context.users.orderby(x => x.name); d.listpricelevel = context.pricelevels.getnewbindinglist(); e.result = d;
the problem 3rd line (d.tbuser = ... ) being lazy-loaded. sure, can do:
context.users.orderby( x => x.name ).tolist();
but again, not bindable list, changes made won't propagate db.
so think need like:
d.tbuser = context.users.orderby( x => x.name ).getnewbindinglist();
but doesn't work. goal is: retrieve list of users, ordered name bind-able list. ideas?
thanks time!
adding orderby
(like of other query functions) turns query iqueryable<tentity>
. fortunately, linq-to-sql's internal query type (dataquery<tentity>
) provides bindinglist<tentity>
via implementation of ilistsource
.
to bindinglist
given query, can this:
var bindinglist = ((ilistsource)query).getlist();
in case:
d.tbuser = ((ilistsource)context.users.orderby(x => x.name)).getlist();
while return type of getlist
ilist
, is, in fact, actual bindinglist<user>
.
Comments
Post a Comment