Example #1
0
 public IEnumerable <OrderItemListModel> GetOrderItemListDataByOrderId(string orderId)
 {
     return((from orderItemList in HuahuiDbContext.OrderItemList.Where(w => w.OrderId.Equals(orderId))
             join orderJoin in HuahuiDbContext.Order on orderItemList.OrderId equals orderJoin.Id into OrderItemListJoinOrder
             from order in OrderItemListJoinOrder.DefaultIfEmpty()
             join customerJoin in HuahuiDbContext.Customer on order.UserId equals customerJoin.Id into OrderJoinCustomer
             from customer in OrderJoinCustomer.DefaultIfEmpty()
             join saleJoin in HuahuiDbContext.Sale on customer.SaleId equals saleJoin.Id into CustomerJoinSale
             from sale in CustomerJoinSale.DefaultIfEmpty()
             join productJoin in HuahuiDbContext.Product on orderItemList.ProductId equals productJoin.Id into OrderItemListJoinProduct
             from product in OrderItemListJoinProduct.DefaultIfEmpty()
             join productGroupJoin in HuahuiDbContext.ProductGroup on product.ProductGroupCode equals productGroupJoin.Code into ProductJoinProductGroup
             from productGroup in ProductJoinProductGroup.DefaultIfEmpty()
             select new OrderItemListModel
     {
         Id = orderItemList.Id,
         OrderId = orderItemList.OrderId,
         ProductId = orderItemList.ProductId,
         Quantity = orderItemList.Quantity,
         TotalPrice = orderItemList.TotalPrice,
         CreatedDateTime = orderItemList.CreatedDateTime,
         ProductName = product.Name,
         IsPromotion = product.IsPromotion,
         ProductGroupCode = product.ProductGroupCode,
         UnitPrice = productGroup.UnitPrice,
         PictureFileName = product.PictureFileName,
         CustomerName = customer.Firstname + " " + customer.Lastname,
         CustomerAddress = customer.Address,
         CustomerPhoneNumber = customer.PhoneNumber,
         SaleName = sale.Firstname + " " + sale.Lastname
     }).GroupBy(g => g.Id).Select(s => s.First()).ToList());
 }
Example #2
0
 public IEnumerable <OrderItemListModel> GetOrderItemList()
 {
     return((from orderItemList in HuahuiDbContext.OrderItemList
             join productJoin in HuahuiDbContext.Product on orderItemList.ProductId equals productJoin.Id into OrderItemListJoinProduct
             from product in OrderItemListJoinProduct.DefaultIfEmpty()
             join productGroupJoin in HuahuiDbContext.ProductGroup on product.ProductGroupCode equals productGroupJoin.Code into ProductJoinProductGroup
             from productGroup in ProductJoinProductGroup.DefaultIfEmpty()
             select new OrderItemListModel
     {
         Id = orderItemList.Id,
         OrderId = orderItemList.OrderId,
         ProductId = orderItemList.ProductId,
         Quantity = orderItemList.Quantity,
         TotalPrice = orderItemList.TotalPrice,
         CreatedDateTime = orderItemList.CreatedDateTime,
         ProductName = product.Name,
         ProductGroupCode = product.ProductGroupCode,
         PictureFileName = product.PictureFileName,
         IsPromotion = product.IsPromotion,
         UnitPrice = productGroup.UnitPrice
     }).GroupBy(g => g.Id).Select(s => s.First()).ToList());
 }