【发布时间】:2017-04-19 13:13:22
【问题描述】:
List < Special > spl = new List < Special > ();
DBEntities entity = new DBEntities();
DateTime ? startDate = Convert.ToDateTime("2017-01-01");
DateTime ? end = Convert.ToDateTime("2017-04-18");
IEnumerable < Object > splist = entity.spGetData(startDate, end, "AAA").ToList();
public class Special {
public int ? NO {
get;
set;
}
public string[] SNo {
get;
set;
}
public string[] Div {
get;
set;
}
public string[] ITEMO {
get;
set;
}
public DateTime ? DDT {
get;
set;
}
}
我有一个存储过程,它返回一些我通过实体框架访问的记录集。但返回类型是 system.data.entity.core.objects.objectresult 并且我想将它映射/添加到我的用户定义的类中。它说的是 Unable to cast object of type..... 我将它转换为 IEnumerable List 但我想遍历每条记录并制作我自己的自定义选定对象列表并拉出特殊类对象中的数据。
【问题讨论】:
-
请阅读minimal reproducible example以获得更好的帮助。
-
问题与javascript或角度代码无关。请适当标记问题
-
你能提供你的存储过程的代码吗?如果不知道返回数据的结构,就无法知道您的类/对象是否会正确映射它。