Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - How can I do a simple query in Entity Framework using lambda?

I have an Entity Framework model semi-working right now, but I'm having trouble performing a query to return database records with a Where() clause.

I am trying to line:

db.BlackstoneUsers.Where(u => u.Email == User.Email); 

but I get the exception:

Expression cannot contain lambda expressions

I think this should be simple, but I'm just learning Entity and LINQ/Lambda.

Does anyone have any pointers?

like image 363
Brett Avatar asked Jul 07 '26 22:07

Brett


1 Answers

try setting the email outside the call

var email = User.Email
db.BlackstoneUsers.Where(u => u.Email == email); 
like image 52
Kyle Avatar answered Jul 09 '26 10:07

Kyle