1
如何使用Linq查询返回DateTimeOffset。 我需要从类型的DateTimeOffset的表截止日期如何使用Linq返回DateTimeOffset类型
public DateTimeOffset GetLastDate(Guid Id, Guid AppId)
{
var q = from k in context.Inspections
where k.Id == Id || k.AppId == AppId
select k.Duedate;
return q;
}
不能隐式转换system.Linq.IQueryable到System.DateTimeOffset
最好使用'。单()'如果你想确保你只有一次结果,或者使用'orderby'来控制你得到的多个结果中的哪一个。 – hvd 2012-02-18 00:22:16
与它说..不能隐式转换system.DateTimeOffset?到System.DateTimeOffSet ....我怎样才能返回日期 – GANI 2012-02-18 00:24:53
@ hvd取决于什么是“更好”在这种情况下 - 非常不同的行为,都不一定是正确的。 – 2012-02-18 00:43:07