English 中文(简体)
前往实体,在无数据时,马克斯日期
原标题:Linq to Entities, getting Max date when there is no data

我在此发言:

startDate = (from n in db.Nodes 
where n.SeedID == mySeedID select n.CreatedDate).Max<DateTime>();

如果有数据可查,它会进行罚款。 然而,有些时候,种子是新的,所以没有节点。 该声明产生了一项无效的行动。 我可以在审判/副渔获物中总结这一点。 是否有更好的办法处理这一设想?

最佳回答

可否使用无效的日期?

startDate = (from n in db.Nodes 
             where n.SeedID == mySeedID 
             select (DateTime?)n.CreatedDate).Max<DateTime?>();
问题回答

暂无回答




相关问题
LINQ Training: Native SQL Queries to LINQ

Can anyone point out some good LINQ training resources. Mostly interested in getting some developers that are very skilled with SQL up to speed using Lambda and LINQ queries. They are struggling with ...

How can i write Linq2Entities Query with inner joins

How can I get data from these related entities. I want to get these columns only: Term.Name , related Concept_Term.Weight, related Concept.Id I wrote the SQL but I don t want to use select t....

Linq to enties, insert foreign keys

I am using the ADO entity framework for the first time and am not sure of the best way of inserting db recored that contain foreign keys. this is the code that i am using, I would appreciate any ...

Linq to entity timing problem

I created a data model that has some views from my database as entities,when I create a linq statment that has part of this view s entities ,the time processor take to execute the linq statment is ...

热门标签