如何在存储过程中从SQL中的多个临时表映射多个结果集

问题描述

这两个表是从存储过程中返回的:

select * from #ElectricCost_tbl 
select * from #GasCost_tbl 

这是C#代码

db.Database.Initialize(force: false);

// Create a sql command to execute the stored procedure
var cmd = db.Database.Connection.CreateCommand();
cmd.CommandText = "[dbo].[Financial_First_Sec]";
         
db.Database.Connection.open();

// Run the stored procedure
var reader = cmd.ExecuteReader();

// Read Blogs from the first result set
var existingElectricCost = ((IObjectContextAdapter)db)
    .ObjectContext
    .Translate<ExistingElectricCostModel>(reader,"ElectricCost_tbl",MergeOption.AppendOnly);

// Move to second result set and read Posts
reader.NextResult();
var existingGasCost = ((IObjectContextAdapter)db)
    .ObjectContext
    .Translate<ExistingGasCostModel>(reader,"GasCost_tbl",MergeOption.AppendOnly);

db.Database.Connection.Close();

在这行上出错

var existingElectricCost = ((IObjectContextAdapter)db)
    .ObjectContext
    .Translate<ExistingElectricCostModel>(reader,MergeOption.AppendOnly);

在我的数据库中找不到

“ ElectricCost_tbl”。

救救我!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)