csharp LINQ加入Entity Framework.cs
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp LINQ加入Entity Framework.cs相关的知识,希望对你有一定的参考价值。
private List<SAL_OrderDetailsViewModel> GetAllOrderDetailsById(int orderID)
{
var odList = (from od in dbContext.SAL_OrderDetail
join munit in dbContext.MST_MeasurementUnit
on od.MUnit equals munit.UnitID
join product in dbContext.MST_Product
on od.ProductID equals product.ProductID.ToString()
where od.OrderID == orderID
select new SAL_OrderDetailsViewModel()
{
OrderDetailID = od.OrderDetailID,
OrderID = od.OrderID,
ProductID = product.ProductID,
ProductName = product.ProductName,
ProductCode = product.ProductCode,
Qty = od.Qty,
MUnitID = od.MUnit,
MUnitName = munit.UnitName,
UnitPrice = od.UnitPrice,
Amount = od.Amount
}).ToList();
return odList;
}
private List<SAL_OrderViewModel> GetAllOrders()
{
var list = (from order in dbContext.SAL_Order
join customer in dbContext.MST_Customer
on order.CustomerID equals customer.CustomerID
join branch in dbContext.MST_Branch
on order.BranchID equals branch.BranchID
join invoice in dbContext.MST_InvoiceType
on order.InvoiceType equals invoice.InvoiceTypeID
orderby order.OrderID descending
select new SAL_OrderViewModel()
{
OrderID = order.OrderID,
DocNo = order.DocNo,
DocDate = order.DocDate,
CustomerID = order.CustomerID,
CustomerName = customer.CustomerName,
BranchID = order.BranchID,
BranchName = branch.BranchName,
InvoiceType = order.InvoiceType,
InvoiceTypeName = invoice.InvoiceTypeName,
OrderNo = order.OrderNo,
OrderDate = order.OrderDate,
Remark = order.Remark,
SubTotal = order.SubTotal,
Discount = order.Discount,
NetAmount = order.NetAmount,
DBUserID = order.DBUserID,
UpdateDateTime = order.UpdateDateTime
}).ToList();
return list;
}
以上是关于csharp LINQ加入Entity Framework.cs的主要内容,如果未能解决你的问题,请参考以下文章
csharp 加入LINQ和Lambda
csharp http://root-project.org/work/net/why-you-shouldnt-use-entity-framework-with-transactions/
Linq To Entity 查询条件扩展
csharp CSharp,Linq - 选择以前的,当前的,净的
初识Linq to Entity
linq to entity常用操作