如何编写在Sql server中创建的linq查询 [英] How to write linq query which is created in Sql server

查看:121
本文介绍了如何编写在Sql server中创建的linq查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将其转换为Linq查询



How to convert this into Linq query

select c.CharityNumber,c.oldCharityNumber,c.Name, s.State,  cd.Active 'DeActive'
from  PledgeNet.CharityDetail as cd
inner join PledgeNet.Charity as c on c.CharityID = cd.CharityID
inner join PledgeNet.CharityFederation as cf on c.CharityID = cf.CharityID
inner join PledgeNet.State as s on c.StateID = s.StateID
inner join  PledgeNet.Federation as fedrat on cf.FederationID = fedrat.FederationID
Where cd.Active = 'N'  and fedrat.FederationName = 'MRC' and cd.YearID = 6









请帮帮我把它写成linq





Please help me how to write this as linq

推荐答案

我不会为你录制它,但我给你两个有价值的工具:

http://msdn.microsoft.com/en-us/library/bb425822.aspx [<一个href =http://msdn.microsoft.com/en-us/library/bb425822.aspxtarget =_ blanktitle =New窗口> ^ ]

http://www.linqpad.net/ [< a href =http://www.linqpad.net/target =_ blanktitle =新窗口> ^ ]
I won''t transcribe it for you, but i give you two valuable tools:
http://msdn.microsoft.com/en-us/library/bb425822.aspx[^]
http://www.linqpad.net/[^]


试试这个

try this
var query =
    from cd in PledgeNet.CharityDetail
    join c in PledgeNet.Charity
      on new { c.CharityID } equals new { cd.CharityID }
    join cf in PledgeNet.CharityFederation
      on new { c.CharityID } equals new { cf.CharityID }
    join s in PledgeNet.State
      on new { c.StateID } equals new { s.StateID}
    join fedrat in PledgeNet.Federation
      on new { cf.FederationID } equals new { fedrat.FederationID }
    where cd.Active == 'N' and fedrat.FederationName == 'MRC' and cd.YearID == 6
              select new 
              {
                 c.CharityNumber,c.oldCharityNumber,c.Name, s.State,  cd.Active
              };



快乐编码!

:)


Happy Coding!
:)


这篇关于如何编写在Sql server中创建的linq查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆