I want to add Timespan to DateTime in EntityFramework with MySql Database.
i have tried using DbFunctions.AddMinutes(someminutes)
and EntityFunctions.AddMinutes(someminutes)
but when i execute i get exception something like
FUNCTION projectName.AddMinutes does not exist
i have googled but cannot find how to execute canonical function. though there is a list of function but again i don't know which class they belong
https://msdn.microsoft.com/en-us/library/bb738563.aspx
I am using
- MySql.Data.Entities 6.8.3.0
- EntityFramework 6.0.0
- MySql.Data 6.8.4
- MySql.Web 6.8.4
- MySql (Database) 5.6.17
My Linq Query is as below
IQueryable<OrderViewModel> orders = _dbContext.Orders
.OrderByDescending(x => x.ID)
.Select(x => new OrderViewModel
{ ID = x.ID,
AddedOn = DbFunctions.AddMinutes(x.AddedOn, diffMinutes).Value,
Customer = (x.IsGuestCheckOut == true ? x.CustomerEmail : x.Customer.FirstName + " " + x.Customer.LastName),
Phone = x.Phone,
TotalAmount = x.TotalAmount,
OrderStatus = x.OrderStatus });
down the road some where condition and pagination is applied
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…