I have the following Transact-Sql that I am trying to convert to LINQ ... and struggling.
SELECT * FROM Project
WHERE Project.ProjectId IN (SELECT ProjectId FROM ProjectMember Where MemberId = 'a45bd16d-9be0-421b-b5bf-143d334c8155')
Any help would be greatly appreciated ... I would like to do it with Lambda expressions, if possible.
Thanks in advance!
GFrizzle beat me to it. But here is a C# version
And as a bonus a purely LINQ method chain version as well:
In this context, you can just use .Contains(), something like this:
No need for a lambda, you've just got a simple LINQ join here:
You probably want the Any() operator:
Since the result set of
db.ProjectMembers.Where(...)
will always be the same, you can split it up so that it's executed only once: