开发者

Why no intellisense when LINQ statement has no where clause?

开发者 https://www.devze.com 2022-12-21 14:08 出处:网络
Can anyone tell me why I do not get intellisense with this code: var testDocuments = (from u in db.TestDocuments

Can anyone tell me why I do not get intellisense with this code:

var testDocuments = (from u in db.TestDocuments
                     orderby u.WhenCreated de开发者_高级运维scending
                     select u).

but I do get intellisense with this code:

var testDocuments = (from u in db.TestDocuments
                     orderby u.WhenCreated descending
                     where 1==1
                     select u).


I was in the similar situation, then I added the following line..

using System.Linq;


When I run into this kind of problem I switch my coding style a little:

var testDocuments = (from u in db.TestDocuments
                     orderby u.WhenCreated descending
                     select u).

Translates into

var testDocuments = db.TestDocuments.OrderBy(u => u.WhenCreated).

And assuming the Linq object is valid it will pull up the intellisense.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号