Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why no intellisense when LINQ statement has no where clause?

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).
like image 398
Edward Tanguay Avatar asked Feb 26 '10 13:02

Edward Tanguay


2 Answers

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

using System.Linq;
like image 186
Peter Qiu Avatar answered Nov 03 '22 09:11

Peter Qiu


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.

like image 21
thaBadDawg Avatar answered Nov 03 '22 07:11

thaBadDawg