Why no intellisense when LINQ statement has no where clause?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 07:57:11

问题


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

var testDocuments = (from u in db.TestDocuments
                     orderby u.WhenCreated descending
                     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).

回答1:


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.




回答2:


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

using System.Linq;


来源:https://stackoverflow.com/questions/2341763/why-no-intellisense-when-linq-statement-has-no-where-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!