2013年5月28日 星期二

[C#] Linq extension: GroupJoin By

///查詢每個月需要用膳的數目
///GroupJoin by CheckInOn月份,
var B = db.Reservations.Where(x => x.IsDinner == true);
var _dinnerInfo = A.GroupJoin( B,
                 x => x, //母體Ajoin key
                 y => y.CheckInOn.Month, //子體Bjoin key
                 (x, y) =>
                 new
                 {
                    Month = x,
                    IsDinner = "需要用餐的訂房數",
                    Count = y.Count()
                  });

沒有留言:

張貼留言