我有两列,“添加日期”和“修改日期”。
我想按修改日期订购所有产品,但由于它可以为空,我想在这种情况下添加日期。
var q = from c in db.Products
where c.UserID == UserID
orderby c.DateModified ?? c.DateAdded descending
select
new ManageProducts
{
ID = c.ID,
Image = c.Photo.PhotoFile,
Name = c.Name,
DateAdded = (DateTime) c.DateModified ?? c.DateAdded
};
这告诉我一个错误
DateAdded = (DateTime) c.DateModified ?? c.DateAdded