entity framework - Getting the Error in my code when framing LINQ -


my code:

var lastname = employees    .where(a => a.number ==       (dm.mtm.where(b => b.mtt.ismanager)              .select(c => c.number)              .firstordefault()))    .select(z => z.lastname)    .firstordefault(); 

error message:

unable create constant value of type 'xxx.models.mt.mtm'. primitive types or enumeration types supported in context.  

try:

int? num = dm.mtm.where(b => b.mtt.ismanager).select(c => c.number).firstordefault(); var lastname = employees.where(a => a.number == num).select(z => z.lastname).firstordefault(); 

but should add check

if (num == null) {     // bad things, don't execute second query } 

between 2 instructions.

the error because in entity framework query can't "things" fancy, things necessary calculate num.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -