检查下面的代码。问题来自lk_GetThirdpartyDataByAsins
存储过程,我正在获取ThirdPartyData
模型类型数据,但错误表明它无法将其转换为ThirdPartyData
。有什么办法解决吗?预先感谢
错误图片:
using (var ctx = new db_exampleEntities())
{
string patternedString = string.Join("", itemstoUpdate.Select(tpdToString));
ThirdPartyData MissedData = ctx.lk_GetThirdpartyDataByAsins(patternedString, itemstoUpdate.FirstOrDefault().Type).ToList();
itemstoUpdate.AddRange(MissedData);
}
答案 0 :(得分:3)
您正在尝试将List<ThirdPartyData>
转换为ThirdPartyData
更改此行:
ThirdPartyData MissedData = ctx.lk_GetThirdpartyDataByAsins(patternedString, itemstoUpdate.FirstOrDefault().Type).ToList();
至:
List<ThirdPartyData> MissedData = ctx.lk_GetThirdpartyDataByAsins(patternedString, itemstoUpdate.FirstOrDefault().Type)
.Select(s=> new ThirdPartyData(){
a= s.a,
...
z=s.z
}).ToList()