您好。我想将LINQ查询转换为SQL查询。我是LINQ的新手。有人可以帮我转换吗?这是我的Linq代码:
var val = from AppDetails in db.ApplicantProfile
join PRQDetails in db.PrqcreatedInformation on AppDetails.ApplicantProfileId equals PRQDetails.ApplicantId
where PRQDetails.ConsiderForPrq == true
orderby PRQDetails.Entrydate ascending
select new
{
Prefix = AppDetails.Prefix.Name,
FirstName = AppDetails.FirstName,
MiddleName = AppDetails.MiddleName,
LastName = AppDetails.LastName,
ArdisPersonId = AppDetails.ArdisPersonId,
ApplicantProfileId = AppDetails.ApplicantProfileId,
PRQEntryDate = PRQDetails.Entrydate,
PrqUpdated = PRQDetails.PrqUpdated,
IsSendtoARDs = PRQDetails.IsSendtoArds,
DataSentToARDis=PRQDetails.DataSentToArdis,
DataSentToARDisBy=PRQDetails.DataSentToArdisBy
};
答案 0 :(得分:4)
这将是:
SELECT
p.Name,
ad.FirstName,
ad.MiddleName,
ad.LastName,
ad.ArdisPersonId,
ad.ApplicationProfileId,
prq.Entrydate,
prq.PrqUpdated,
prq.IsSendtoArds,
prq.DataSentToArdis,
prq.DataSentToArdisBy
FROM AppDetails ad
INNER JOIN PRQDetails prq
ON ad.ApplicantProfileId = prq.ApplicantId
INNER JOIN Prefix p
ON ?????? = ?????
WHERE prq.ConsiderForPrq = 1
ORDER BY prq.Entrydate
但如果没有关于AppDetails
如何链接到Prefix
的信息,则很难填写????
答案 1 :(得分:1)
以下是来自MSDN http://msdn.microsoft.com/en-us/library/Bb386961(v=VS.90).aspx
的示例请注意,在他们的示例中,变量db是DatabaseContext。