0

你好。我想将 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 
                  };
4

2 回答 2

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的信息很难填写????

于 2012-10-18T11:43:50.047 回答
1

这是来自 MSDN http://msdn.microsoft.com/en-us/library/Bb386961(v=VS.90).aspx的示例

请注意,在他们的示例中,变量 db 是 DatabaseContext。

于 2012-10-18T11:44:33.587 回答