Pregunta

all

Below is my query code:

var users = db.users.where(u=> u.id=5 && db.usergroups.any(d=>d.user_id=u.id))

Build the expression tree for the condition u.id=5 is easy, but who can tell me how to build the condition db.usergroups.any(d=>d.user_id=u.id)

thanks

¿Fue útil?

Solución

The simplest way to obtain the expression created by the C# compiler is to affect it to a variable of the correct type, and looking at it in a debugger; in your case:

Expression<Func<User, bool>> lambdaExpression =
    u => u.id == 5 && db.UserGroups.Any(d => d.user_id == u.id);

And then look at the lambdaExpression variable in a debugger.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top