为什么LINQ语句时没有where子句没有智能感知? [英] Why no intellisense when LINQ statement has no where clause?

查看:108
本文介绍了为什么LINQ语句时没有where子句没有智能感知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我为什么我的此代码获得智能:

  VAR testDocuments =(从u在db.TestDocuments 
排序依据u.WhenCreated降
选择U)。



但我的此代码获得智能:

  VAR testDocuments =(从u在db.TestDocuments 
排序依据u.WhenCreated降
,其中1 == 1
。选择所需U)。


解决方案

当我碰到这样的问题将我的编码风格一点:

  VAR testDocuments =(从u在db.TestDocuments 
排序依据u.WhenCreated降
选择U)。



转换成

  VAR testDocuments = db.TestDocuments.OrderBy(U => u.WhenCreated)。 

和假设LINQ的对象是有效的,将拉起智能感知。


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).

解决方案

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.

这篇关于为什么LINQ语句时没有where子句没有智能感知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆