【发布时间】:2019-11-28 17:06:29
【问题描述】:
是否可以从ObjectContext 对象中读取元组列表?
我在存储过程中有类似这样的数据库查询
SELECT
T.Id as Item1, -- this is guid
T.WorkflowId AS Item2, -- this is int
T.ActionName AS Item3 -- this is string
FROM
MyTable T
我正在尝试像这样阅读它的 c# 代码
var command = context.Database.Connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "[SEQUOIA].[GetWriteOffRequestDetails]";
var objectContext = ((IObjectContextAdapter)context);
context.Database.Connection.Open();
if (reader.NextResult())
{
// this line is giving error, so basically where it is trying to read/translate the result
List<Tuple<Guid, int, string>> requestItemActions = objectContext.ObjectContext.Translate<Tuple<Guid, int, string>>(reader).Select(x => new Tuple<Guid, int, string>(x.Item1, x.Item2, x.Item3)).ToList();
}
但是它抛出了这个异常
结果类型 'System.Tuple`3[System.Guid,System.Int32,System.String]' 可能不是 抽象且必须包含默认构造函数。
那么甚至可以像这样读取元组吗?
如果是,谁能指出我错过了什么?
【问题讨论】:
标签: c# sql sql-server tuples