Мне нужно обновить поле IsIgnored, основываясь на senderId, когда я проверяю, где условие. Оно не идентифицирует senderId, который я сравнивал из цикла. Он генерирует исключение, например, неоднозначное имя столбца senderid.1001 *
foreach (var senderId in senderIdList)
{
using (var context = new BSoftWEDIIContext())
{
var ediDocuments = context.EDIDocuments.SqlQuery("Update EDIDocument SET IsIgnored=1 from EDIDocument edi inner JOIN FileDetails files on edi.FileDetailsId = files.Id where edi.IsDeleted = 0 and edi.SenderID =senderId and edi.DocumentTypeID != 3 and edi.DocumentTypeID != 5 and edi.DocumentTypeID != 2 and edi.IsIgnored = 0 and files.IsDeleted = 0" );
}
Попробовал так:
var ediDocuments = context.EDIDocuments.SqlQuery("Update EDIDocument SET IsIgnored=1 from EDIDocument edi inner JOIN FileDetails files on edi.FileDetailsId = files.Id where edi.IsDeleted = 0 and edi.SenderID ='149825353' and edi.DocumentTypeID != 3 and edi.DocumentTypeID != 5 and edi.DocumentTypeID != 2 and edi.IsIgnored = 0 and files.IsDeleted = 0", new SqlParameter
{
ParameterName = "senderId",
DbType = System.Data.DbType.String,
Value = senderId
});
foreach (var senderId in senderIdList)
{
using (var context = new BSoftWEDIIContext())
{
var ediDocuments = context.EDIDocuments.SqlQuery("Update EDIDocument SET IsIgnored=1 from EDIDocument edi inner JOIN FileDetails files on edi.FileDetailsId = files.Id where edi.IsDeleted = 0 and edi.SenderID=@senderId and edi.DocumentTypeID != 3 and edi.DocumentTypeID != 5 and edi.DocumentTypeID != 2 and edi.IsIgnored = 0 and files.IsDeleted = 0", new SqlParameter("@senderId", senderId));