c# - Get entities that are not linked -
i have items , lines linked itemslines table.
on web page, show item. want display in dropdownlist lines not linked item.
this doesn't work :
int itemid = convert.toint32(request.querystring["id"]); ddllines.datasource = context.lines.where(t => !t.itemlines.any(x => x.itemid == itemid));
i trying lines where(they not associated item).
i can't figure out how this.
thank much!
edit :
this error message get:
the objectcontext instance has been disposed , can no longer used
your error not because lambda expression incorrect. issue context object using connect database has been disposed of before call:
ddllines.datasource = context.lines.where(t => !t.itemlines.any(x => x.itemid == itemid));
the solution add .tolist() end of expression. because .where lambda expression returns iqueryable interface , interface still has connection database. adding .tolist() remove connection database.
Comments
Post a Comment