In Query 的 Linq 表达式链语法

发布于 2024-10-19 12:55:42 字数 199 浏览 7 评论 0原文

我有一个查询,似乎无法在表达式方法链语法中复制。我有两个表“User”和“UserPayment”。 User 和 UserPayment 具有一对多的关系,即一个 User 可以有多个 UserPayment。

只是想知道获取在特定日期付款的所有用户的语法是什么?或者甚至获取所有已付款的用户?

另请注意,我是用 VB 编写的。

谢谢

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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巷雨优美回忆 2024-10-26 12:55:42

听起来您也许可以点击 UserPayments,使用 where 子句按日期进行过滤,并从那里获取不同的用户。

像这样的东西吗?

 Dim users = From up In db.UserPayments _
    Where up.PaymentDate >= someDate _
    Select up.User Distinct

VB 点表示法让我无法理解,但在 C# 中,我会这样做(抱歉,我无法准确地告诉您您正在寻找的内容):

var users = db.UserPayments.Where(x=>x.PayDate.Date == someDate)
                           .Select(x=>x.User)
                           .Distinct();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文