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

下面这句SQL 如何转换为LINQ
SELECT   COUNT(BarCode)   FROM [WMSV2_DEV].[dbo].[InBoundFormDetail] WHERE  InBoundFormDetail.InBoundFormsId='120' group by [ProductId]      ,[ProductCode]      ,[ProducedDate]      ,[LotNumber]      ,[ProdPlaceId]      ,[Comment]      ,[Location1]      ,[Location2]

------解决方案--------------------
var query=from q in InBoundFormDetail
          where q.InBoundFormsId == "120"
          group q by new {q.ProductId, q.ProductCode, q.ProducedDate, q.LotNumber,
                          q.ProdPlaceId, q.Comment, q.Location1, q.Location2} into g
          select new {count= g.Count()};