How to do paging processing for this dynamic query in Entity Framework 6 ?
BillDetailLogsDto
is a custom result DTO not an database entity,how to sqlquery include navigation properties and It is impossible to pass parameters without using SqlParameter How to implement sqlquery use .Where
.OrderBy
extend
using (ProjectDbContext context = new ProjectDbContext())
{
var query = context.Database.SqlQuery<BillDetailLogsDto>("SELECT *, SUM(Amount) OVER (ORDER BY Id) AS QSAmount FROM BillDetailLogs").AsQueryable();
var result = query.Select(t => new
{
CustomerName = t.Customer.Name,
t.CustomerId,
t.Type,
t.SortId,
t.Amount,
QAmount=t.QSAmount,
t.ObjDate,
t.OpRemark,
t.Remark,
t.SendOrderId,
CreatedUserName = t.CreatedUser.RealName,
t.CreatedDate,
}).OrderByDescending(t => t.SortId);
return Json(result, JsonRequestBehavior.AllowGet);
}