如何确定LINQ查询SELECT变量的位置 [英] How to make the position of a LINQ Query SELECT variable

查看:67
本文介绍了如何确定LINQ查询SELECT变量的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过不使用属性而是使用列名来使LINQ SELECT更灵活? 也许一个例子会有所帮助..我正在尝试执行以下操作(伪代码):

Is it possible to make the LINQ SELECT more flexible by not working with properties but with the column name? Maybe an example will help..I'm trying to do the following (pseudocode):

From x In Entities
Where ...
Select("ID", "Value" , "Date")

但是根据某些选择,我希望结果以不同的顺序

but depending on certain choices, I would like to have the result in different order

From x In Entities
Where ...
Select("Value", "Date", "ID" )

或者其他数量的SELECT结果

Or another amount of SELECT results

From x In Entities
Where ...
Select("Value")

任何使它尽可能动态的帮助都将是令人敬畏的! tnx

Any help to make this as dynamic as possible would be AWESOME! tnx

推荐答案

也许这会对您有所帮助

from x In Entities
where ... select new {
  Value = x["Value"],
  Date = x["Date"],
  ID = x["ID"]
}

这篇关于如何确定LINQ查询SELECT变量的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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