Linq Expression Chain Syntax for In Query
I have a query that I cannot seem to replicate in expression method chain syntax. I have two tables "User" and "UserPayment". User and UserPayment have a one开发者_如何学JAVA to many relation i.e. One User can have many UserPayments.
Just wondering what the syntax is to get all users that have made a payment on a certain date? Or even get all users that have made a payment at all?
Also to note I am writing in VB.
Thanks
Sounds like you might be able to hit the UserPayments, use a where
clause to filter by your date, and get the distinct Users from there.
Something like this?
Dim users = From up In db.UserPayments _
Where up.PaymentDate >= someDate _
Select up.User Distinct
The VB dot-notation escapes me, but in C#, I'd do this (sorry I can't get you quite exactly what you're looking for):
var users = db.UserPayments.Where(x=>x.PayDate.Date == someDate)
.Select(x=>x.User)
.Distinct();
精彩评论