2
考虑下面的存储过程:返回匿名类型的存储过程LINQ2SQL
SELECT * FROM Customers;
SELECT Customer.Id, Customer.Name, Order.Total, Order.DateOrdered
FROM Customers INNER JOIN Orders ON Customers.Id = Orders.CustomerId;
过程显然返回一个我试图检索与此部分类方法两个结果集:
public partial class DBSproc : DataContext
{
[Function(Name = "dbo.spGetCustomersAndOrders")]
[ResultType(typeof(Customer))]
// What type should I use here for the second resultset?
[ResultType(typeof(... what here? ...))]
public IMultipleResults GetCustomersAndOrders()
{
IExecuteResult result =
this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())));
return (IMultipleResults)(result.ReturnValue);
}
}
我知道第一个结果集将映射到Customer实体,但第二个结果集呢?第二个是自定义选择,组合多个表中的多个列。我没有这些属性的实体。
我应该为该结果集创建一个虚拟实体吗?我希望我能以某种方式使用匿名类型进行这种即席查询。
感谢。
耻辱看到这个问题没有“有用”的答案,我希望会有一个! – Jon 2010-01-05 04:38:20