var q = (from Labels in dc.tblArtworkDataLabels select Labels).ToList();
但是我需要这样做等效于:
SELECT     d.ID, d.labelID, d.dataID, d.data, l.templateID
FROM         tblArtworkDataLabels AS d INNER JOIN
                      tblArtworkData AS l ON d.dataID = l.ID
WHERE     (l.templateID = 238)
如何在LINQ中做到这一点?
编辑
抱歉!错过了原始statmenet上的WHERE子句!

最佳答案

var result = dc.tblArtworkDataLabels
    .Join(dc.tblArtworkData, l => l.ID, d => d.dataID, (l, d) => new {l, d})
    .Select(o => new {
         Id = o.d.ID,
         LabelId = o.d.labelID,
         DataId = o.d.dataID,
         Data = o.d.data,
         TemplateId = o.l.templateID,
     })
    .Where(o => o.l.templateID == 238);

09-25 21:00