Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinqPad Not Returning Results With C# Statements

Tags:

sql

linq

It's late, so this must be something stupid. I have LinqPad connected up to my database and cannot seem to get results for the simplest of queries.

var q = from app in AppInstances  select new {  AppId = app.AppId  }; 

When I run that, LinqPad says that it executed successfully (C#Statement mode). Nothing is retured.

I can write the following very simple Lambda (C# expression mode):

AppInstances.Select (p => p.AppId) 

And that works. Why? I would prefer to use the non-lambda query building functionality. I am sure that this is something all together silly.

like image 888
Brandon Watson Avatar asked Dec 15 '10 08:12

Brandon Watson


1 Answers

I would expect that in statement mode, you'd have to do something like call q.Dump(); to see the results.

But if you just want to use query expressions, why not do that from expression mode? Just use an expression of:

from app in AppInstances select new {     AppId = app.AppId }; 

Or to make it equivalent to your original lambda:

from app in AppInstances select app.AppId 
like image 122
Jon Skeet Avatar answered Oct 14 '22 02:10

Jon Skeet