Linq To Entities问题
在Linq表达式里 怎么将 DateTime? 转换为 DateTime 呀?
直接 Convert.ToDateTime 会报 不识别方法XXX...
还有没有别的方法啊~
我试过用String类型来接受 但是一样不识别
求高手解惑啊~...急...
------最佳解决方案-------------------- 先转化成linq2object再执行查询:
eg:
var query=from t in db.User.ToList()
where t.BirthDay!=null && Convert.ToDateTime (t.BirthDay) < DateTime.Now
select t;
------其他解决方案--------------------
IncidentCombinViewModelQueryable = IncidentAppealInformationQueryable
.Select(q=> new IndidentCombineViewModel)
{
Title = q.IncidentTitle,
IncidentTypeId = q.IncidentTypeId,
QueryTime = q.IncidentTime.Value,
IncidentAppealInformarionId = q.IncidentAppealInformationId
}
------其他解决方案-------------------- IncidentCombinViewModelQueryable = IncidentAppealInformationQueryable
.Select(q=> new IndidentCombineViewModel)
{
Title = q.IncidentTitle,
IncidentTypeId = q.IncidentTypeId,
QueryTime =q.IncidentTime.HasValue? q.IncidentTime.Value:DateTime.MinValue,
IncidentAppealInformarionId = q.IncidentAppealInformationId
}
http://topic.csdn.net/u/20120313/14/6c6cc393-70dd-43ca-9d00-e6a8e2e9abd8.html
------其他解决方案-------------------- let t = x.Time
where t != null
select t.value
------其他解决方案-------------------- DateTime = DateTime?.HasValue ? DateTime?.Value:DateTime.Now;
------其他解决方案-------------------- 引用: 先转化成linq2object再执行查询:
eg:
var query=from t in db.User.ToList()
where t.BirthDay!=null && Convert.ToDateTime (t.BirthDay) < DateTime.Now
select t;
能详细说下么:我的代码是这样的:
IQueryable<IndidentCombineViewModel> IncidentCombinViewModelQueryable = null;
IQueryable<IncidentAppealInfomarion> IncidentAppealInformationQueryable = iIncidentApplInfomationRepository.GetQuery(true);
IncidentCombinViewModelQueryable = IncidentAppealInformationQueryable
.Select(q=> new IndidentCombineViewModel)
{
Title = q.IncidentTitle,
IncidentTypeId = q.IncidentTypeId,
QueryTime = Convert.ToDateTime(q.IncidentTime),
IncidentAppealInformarionId = q.IncidentAppealInformationId
}
return IncidentCombinViewModelQueryable;
------其他解决方案-------------------- 引用: IncidentCombinViewModelQueryable = IncidentAppealInformationQueryable
.Select(q=> new IndidentCombineViewModel)
{
Title = q.IncidentTitle,