日期:2014-05-20  浏览次数:20724 次

求一sql的linq语句
SQL code

SELECT 
(SELECT COUNT(*) FROM TableName WHERE CODE=a.CODE)AS [COUNT]
,*
FROM TableName as a
WHERE [ID] = '30BCA6A3-0B18-4224-9248-14E2CD3F20B6'



这个linq怎么写呢?

------解决方案--------------------
Hi zhengmushang,
Try this

C# code
var query=from a in db.TableName
          where a.ID=="30BCA6A3-0B18-4224-9248-14E2CD3F20B6"
          select new 
        { 
            Count=db.TableName.Where(b=>b.CODE==a.CODE).Count(),
            a
        };