我试图找出如何从其存储过程接收数据时,如果它是一个数据透视表,并且在其结果集中具有动态no列。我用来创建1月到12月的年度总数的最终集合。我不知道如何解决这个类需要事先定义的想法。任何人,提前谢谢..
public class rptQuoteSwitchChart
{
[StringLength(3)]
public string Month { get; set; }
public int s2015 { get; set; } // This column is dynamic (source is a pivot statement)
public int s2016 { get; set; } // This column is dynamic (source is a pivot statement)
}
public ICollection<rptQuoteSwitchChart> RunStoredProcedureQuoteSwitchChart()
{
ICollection<rptQuoteSwitchChart> result = new List<rptQuoteSwitchChart>();
try
{
result = _db.Database.SqlQuery<rptQuoteSwitchChart>("EXEC dbo.GetQuotationsHistory").ToList();
return result;
}
catch (Exception ex)
{
writeToErrorLog(ex.InnerException.ToString(), ex.Message, "H");
return result;
}
}