首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Linq To Entities有关问题

2012-12-19 
Linq To Entities问题在Linq表达式里 怎么将 DateTime? 转换为 DateTime 呀?直接 Convert.ToDateTime 会报

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 &amp;&amp;  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,


  IncidentTypeId = q.IncidentTypeId,
  QueryTime =q.In……


UP……

热点排行