【发布时间】:2010-12-14 13:21:18
【问题描述】:
假设我有以下查询:
int x = 5;
var result = from p in db.products
where p.CategoryId == x
select p;
int count = result.Count();
List<product> products = result.ToList();
这就是我现在所拥有的。但另外我需要从结果中获得一个 DataReader:
// that's what I need:
var reader = ConvertSubSonicLinqQueryToDataReader(result);
如何将 linq 语句转换为我可以使用的东西? DataReader 或 DbCommand 甚至是带有参数列表的普通 sql。
我知道 SubSonic 可以做到这一点(因为它无论如何都会将查询转换为普通 sql),但我还没有在公共可访问方法中找到任何东西。
有什么建议吗?
【问题讨论】:
-
你想用 DataReader 做什么?也许我们可以提出一些建议。
-
我必须将 DataReader 传递给第三方方法(将 linq 查询编译为普通的 sql 语句就足够了,这样我就可以使用 InlineQuery)
标签: c# linq subsonic subsonic3