开发者

Can I use this query in the entity 4.0 framework?

开发者 https://www.devze.com 2023-03-30 07:37 出处:网络
I\'m needing some syntax help with the following query please? I\'d like to use an equivalent in the entity framework but I\'m unsure of the syntax.

I'm needing some syntax help with the following query please? I'd like to use an equivalent in the entity framework but I'm unsure of the syntax.

开发者_JS百科

Can someone help me format this to work with the entity framework?

Thanks in advance.

    Select * from (
    SELECT [Member]
      ,[MemberGroup],
    (SELECT [text]
  FROM [umbracoNode]where [id] = [Member]) As MemberName,
(SELECT [text]
  FROM [umbracoNode]where [id] = [MemberGroup]) As GroupName
  FROM [cmsMember2MemberGroup]
) UG
where UG.MemberName is not null
order by UG.MemberName,
UG.GroupName


Try this:

var query =
    from x in db.cmsMember2MemberGroup
    join y in db.umbracoNode on x.Member equals y.id
    let MemberName = y.text
    where MemberName != null
    join z in db.umbracoNode on x.MemberGroup equals z.id
    let GroupName = z.text
    orderby new { MemberName, GroupName }
    select new
    {
        x.Member,
        x.MemberGroup,
        MemberName,
        GroupName,
    };


Is there a particular reason that this query is in this format?

Why are there not use of joins?

Need to really understand what you want here first and get into better sql before going to linq.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号