LINQ to Entities 查询,用于从 co 表中选择内容并将该表与 cotypes whereco 连接。 cotype =“某个值”; c.someId 是 Max?

发布于 2024-11-05 05:38:32 字数 505 浏览 1 评论 0原文

以下 SQL 查询的 LINQ to Entities 查询是什么?

select Verbiage.verbiage 
from Verbiage
join Verbiage_Types on Verbiage.verbiage_type_id=Verbiage_Types.verbiage_type_id
where Verbiage_Types.verbiage_type='ENROLLMENT'
group by Verbiage.verbiage,Verbiage.sequence
having Verbiage.sequence=(
     select MAX(Verbiage.sequence) 
     from Verbiage 
     join Verbiage_Types on Verbiage.verbiage_type_id=Verbiage_Types.verbiage_type_id 
     where Verbiage_Types.verbiage_type='ENROLLMENT')

What will be the LINQ to Entities query for the following SQL Query ?

select Verbiage.verbiage 
from Verbiage
join Verbiage_Types on Verbiage.verbiage_type_id=Verbiage_Types.verbiage_type_id
where Verbiage_Types.verbiage_type='ENROLLMENT'
group by Verbiage.verbiage,Verbiage.sequence
having Verbiage.sequence=(
     select MAX(Verbiage.sequence) 
     from Verbiage 
     join Verbiage_Types on Verbiage.verbiage_type_id=Verbiage_Types.verbiage_type_id 
     where Verbiage_Types.verbiage_type='ENROLLMENT')

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

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

发布评论

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

评论(2

墨洒年华 2024-11-12 05:38:32

我不确定,但如果这不能做到这一点,那就非常接近了?

    Using db As TestContext = New TestContext("connectionString")
        Dim result = (From v In db.Verbiages Join vt In db.Verbiage_Types
                      On v.Verbiage_Type_Id Equals vt.Verbiage_Type_Id
                      Where vt.Verbiage_Type = "ENROLLMENT"
                      Group v.Verbiage, v.Sequence By v.Verbiage, v.Sequence Into Group
                      Where Sequence = Group.Max(Function(n) n.Sequence)
                      Select Verbiage)
    End Using

I'm not certain, but if this doesn't do it, it's pretty close?

    Using db As TestContext = New TestContext("connectionString")
        Dim result = (From v In db.Verbiages Join vt In db.Verbiage_Types
                      On v.Verbiage_Type_Id Equals vt.Verbiage_Type_Id
                      Where vt.Verbiage_Type = "ENROLLMENT"
                      Group v.Verbiage, v.Sequence By v.Verbiage, v.Sequence Into Group
                      Where Sequence = Group.Max(Function(n) n.Sequence)
                      Select Verbiage)
    End Using
临风闻羌笛 2024-11-12 05:38:32

实际上答案是

from verbiage in db.Verbiage
join verbiage_types in db.Verbiage_Types on verbiage.verbiage_type_id equals verbiage_types.verbiage_type_id where verbiage_types.verbiage_type == "ENROLLMENT" group verbiage by new { verbiage.verbiage1, verbiage.sequence } into g where   g.Key.sequence == 
(from verbiage0 in db.Verbiage
join verbiage_types1 in db.Verbiage_Types on verbiage0.verbiage_type_id equals verbiage_types1.verbiage_type_id
where
  verbiage_types1.verbiage_type == "ENROLLMENT" select new {
  verbiage0.sequence
}).Max(p => p.sequence) select new { g.Key.verbiage1}

actually the answer is

from verbiage in db.Verbiage
join verbiage_types in db.Verbiage_Types on verbiage.verbiage_type_id equals verbiage_types.verbiage_type_id where verbiage_types.verbiage_type == "ENROLLMENT" group verbiage by new { verbiage.verbiage1, verbiage.sequence } into g where   g.Key.sequence == 
(from verbiage0 in db.Verbiage
join verbiage_types1 in db.Verbiage_Types on verbiage0.verbiage_type_id equals verbiage_types1.verbiage_type_id
where
  verbiage_types1.verbiage_type == "ENROLLMENT" select new {
  verbiage0.sequence
}).Max(p => p.sequence) select new { g.Key.verbiage1}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文