我可以使用 Entity SQL 查询 IQueryable吗?
我知道我可以使用 ESQL 查询 T 的 ObjectSet,但我可以使用它查询 T 的任意 IQueryable 吗?
EDIT
示例:
var originalQuery = from t in Transactions where t.Date < DateTime.Now select t;
// query is now an IQueryable<Transation>. Now I want to do some dynamic manipulations
// on originalQuery by using ESQL
var manipulationQuery = "select t.a as A from T as t";
// I want to execute manipulationQuery over the originalQuery, something like this:
// (this is a hipotetical method. It does not exist)
var transactions = context.RunESQLOverIQueryable(originalQuery, manipulationQuery).ToList();
EDIT 2
实际上,用例如下:我需要程序员编写一个返回表示核心查询的 IQueryable(T) 的方法。该查询将被提供给 ReportControl,该 ReportControl 必须对此查询执行一系列分组依据,以及选择必须检索哪些列等。我认为通过 ESQL 动态操作核心查询是一个不错的选择。我也不确定。
I know I can use ESQL to query an ObjectSet of T
but can I use it to query an arbitrary IQueryable of T
?
EDIT
Example:
var originalQuery = from t in Transactions where t.Date < DateTime.Now select t;
// query is now an IQueryable<Transation>. Now I want to do some dynamic manipulations
// on originalQuery by using ESQL
var manipulationQuery = "select t.a as A from T as t";
// I want to execute manipulationQuery over the originalQuery, something like this:
// (this is a hipotetical method. It does not exist)
var transactions = context.RunESQLOverIQueryable(originalQuery, manipulationQuery).ToList();
EDIT 2
Actually the use case is the following: I need a programmer to code a method that returns an IQueryable(T) representing the core query. This query will be given to a ReportControl that must execute a series of group bys on this query, as well as selecting which columns must be retrieved and so forth. I thought that manipulating the core query dynamically through ESQL is a good choice. I'm not sure either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 动态 Linq 库。它是 Visual studio 2008 示例的一部分,但它适用于 2010以及。
Check Dynamic Linq library. It is part of samples for Visual studio 2008 but it will work with 2010 as well.