我有以下查询,
var sqlQuery = @Update dbo.SampleTable SET Status=@inStatuses, Dates = @inDates WHERE Id = @Ids.
虽然我已准备好参数列表:
var paramStatuses = deliveryInfoForUpdate.Select(pr => pr.statuses).Select(status=> new SqlParameter() { ParameterName = "@inStatuses", Value = status, DbType = DbType.Int32 }).ToList();
var paramIds = deliveryInfoForUpdate.Select(pr => pr.Ids).Select(Id => new SqlParameter() { ParameterName = "@Ids", Value = Id, DbType = DbType.Int64 } ).ToList();
var paramDates = deliveryInfoForUpdate.Select(pr => pr.dates).Select(date=> new SqlParameter() { ParameterName = "@inDates", Value = date, DbType = DbType.DateTime }).ToList();
我正在按照以下方式调用ExecuteSqlCommand方法。
DbContext.Database.ExecuteSqlCommand(sqlQuery,paramStatuses, paramDates,paramIds );
所以,我必须在传递的Ids的基础上更新表的2列(状态,日期)。我怎样才能做到这一点?目前我正在追踪异常
对象类型不存在映射 System.Collections.Generic.List`1 [System.Data.SqlClient.SqlParameter, System.Data,Version = 4.0.0.0,Culture = neutral, PublicKeyToken = b77a5c561934e089]]到已知的托管提供商本机 类型。
感谢。