我需要在[
{
"kode": "8784",
"nama": "drg.MELANI SARI TANJUNG"
},
{
"kode": "8848",
"nama": "drg.ARIEF KURNIAWAN"
},
{
"kode": "8873",
"nama": "drg.SRI ARIANI SUGIARTI"
}
]
中AddYears(2)
。我怎样才能做到这一点?引发异常
select new ShowRequestsModel
答案 0 :(得分:3)
您需要DbFunctions
类(System.Data.Entity
),尤其是它的
AddYears()
方法
var requests = (from req in db.PartRequests
join info in db.UsersInfos on req.UserId equals info.aspnet_UserId
join prodName in db.Products on req.ProductId equals prodName.Id
join partRequestStatus in db.PartRequestStatus on req.PartRequestStatusId equals partRequestStatus.Id
select new ShowRequestsModel
{
WarantyExpirationDate = DbFunctions.AddYears(req.PurchasedDate, 2),
IsWarantyExpired = false
})
.Sort(sortField, sortBy);