如何确定 LINQ 查询 SELECT 变量的位置
是否可以通过不使用属性而是使用列名来使 LINQ SELECT 更加灵活? 也许一个例子会有所帮助..我正在尝试执行以下操作(伪代码):
From x In Entities
Where ...
Select("ID", "Value" , "Date")
但根据某些选择,我希望结果以不同的顺序
From x In Entities
Where ...
Select("Value", "Date", "ID" )
或其他数量的 SELECT 结果
From x In Entities
Where ...
Select("Value")
任何帮助使其尽可能动态太棒了! tnx
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" )
Or another amount of SELECT results
From x In Entities
Where ...
Select("Value")
Any help to make this as dynamic as possible would be AWESOME! tnx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这会对你有帮助
Maybe this will help you
就像我在评论中所说的那样(处理子属性,例如 Type.Name,但不处理多个字段)
我让乐趣来制作多字段版本;)
用法:
Like I said in my comment (handles subproperties, like Type.Name, but not multiple fields)
I let the fun to make the multi field version ;)
Usage: