请问这句sql改成linq怎么写
SELECT [t0].[hotelid],COUNT(*) AS [sellCount], [t1].cname AS [Key]
FROM [dbo].[hotel_user_order] AS [t0]
Left join dbo.hotelinfo [t1] on [t1].id=[t0].hotelid
GROUP BY [t0].[hotelid],[t1].cname
[解决办法]
给一个资料吧
http://www.cnblogs.com/lovecherry/archive/2007/08/17/859826.html
[解决办法]
//Functions left join Resos var result = (from x in Resos join y in RoleFunctionMappings on x.Id equals y.FunctionId into z from y in z.DefaultIfEmpty() select new { ResourceValue = x.ResourceValue, ParentFunctionId = x.ParentFunctionId, x.PagePath, Id = x.Id, x.FunctionType, FunctionCode = x.FunctionCode, MappingId = y == null ? -1 : y.Id, IsDeny = y == null ? false : y.IsDeny, IsDefaultFunction = y == null ? false : y.IsDefaultFunction, x.Level , x.ShowSequence }).OrderBy(Item=>Item.Level).ThenBy(item=>item.ShowSequence);
[解决办法]
var query= from to in db.hotel_user_order join t1 in db.hotelinfo on to.hotelid equals t1.id into left from t1 in left.DefaultIfEmpty() group to by new {to.hotelid,t1.cname} into g select new { hotelid=g.Key.hotelid, sellCount=g.Count(), cname=g.Key.cname };
[解决办法]