我正在创建一个Web API,它将使用存储过程使用Entity Framework数据库优先方法从表中获取信息。 s = pd.Series(dict_f)
#if keys are strings, convert to tuples
s.index = s.index.str.strip('()').str.split(',', expand=True)
print (s)
1515 32 [0.92, 0.11, 0.65]
42 56 [0.2, 0.5, 0.23]
4312 5135 [0, 0.11, 0.22]
dtype: object
df1 = s.reset_index()
df1.columns = ['key1','key2','features']
print (df1)
key1 key2 features
0 1515 32 [0.92, 0.11, 0.65]
1 42 56 [0.2, 0.5, 0.23]
2 4312 5135 [0, 0.11, 0.22]
是在Entity Framework中创建的复杂类型对象。我循环导入函数'connection1' => array(
'driver' => 'mysql',
'host' => '*****.*****.co.za',
'database' => 'abc',
'username' => 'root',
'password' => '*****',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'connection2' => array(
'driver' => 'mysql',
'host' => '*****.*****.co.za',
'database' => 'xyz',
'username' => 'root',
'password' => '********',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
并填充复杂类型。我在尝试访问数据访问层时在业务层中收到错误
我得到的错误是以下代码
ListAllTeams_Result
查询结果不能多次枚举。
注意:此错误位于内部堆栈中,并且不会停止执行应用程序
GetAllTeams()
致电'阅读'当数据阅读器关闭时不是有效的操作。
注意:这会停止执行
业务层
var team = _teamRepository.GetAllTeams();
DataAccess图层:
foreach (var t in team)
答案 0 :(得分:0)
我发现了问题所在。我不得不在回报中添加ToList
using (var mcrContext = new MCREntities())
{
return (from team in mcrContext.ListAllTeams("")
select new ListAllTeams_Result
{
TeamID = team.TeamID,
TeamName = team.TeamName,
TeamDescription = team.TeamDescription,
CountryCode = team.CountryCode,
CreatedBy = team.CreatedBy,
CreatedDate = team.CreatedDate,
ModifiedBy = team.ModifiedBy,
ModifiedDate = team.ModifiedDate
}).ToList();
}