c# - error when converting linq lambda query to list -
i trying query data using linq, joining 2 tables id == id of second table. getting exception error saying
cannot implicitly convert type '
system.collections.generic.list<anonymoustype#1>
' 'system.collections.generic.list<--db table here-->
'.
var qry = context.projects .join(context.members, p => p.id, m => m.id, (p, m) => new { p, m }) .where(u => u.m.id == memid) .select(b => new { b.p.projname, b.p.projdesc, b.p.projecttype, b.p.tags }); return qry.tolist();
you trying return list of anonymous type method return type list<sometype>
.
so instead of creating anonymous objects need create objects of type.
.select(b => new sometype { // set properties here });
Comments
Post a Comment