开发者

LinqPad Not Returning Results With C# Statements

开发者 https://www.devze.com 2023-01-30 10:46 出处:网络
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.

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.


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
0

精彩评论

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