В какой строке я получаю сообщение «Объект с нулевым значением должен иметь значение?» [закрыто]C#

Место общения программистов C#
Ответить
Anonymous
 В какой строке я получаю сообщение «Объект с нулевым значением должен иметь значение?» [закрыто]

Сообщение Anonymous »

У меня есть этот код.

Код: Выделить всё

var res = new GetItemSerialForViewDto()

{

ItemSerial = new ItemSerialDto

{

Index = index,

SerialValue = string.IsNullOrEmpty(o.SerialValue) ? "" : o.SerialValue,

WarrantyStartDate = o.WarrantyStartDate,

WarrantyEndDate = o.WarrantyEndDate,

Notes = string.IsNullOrEmpty(o.Notes) ? "" : o.Notes,

Id = o.Id,

VendorName = string.IsNullOrEmpty(o.VendorName) ? "" : o.VendorName,

ItemPartNumber = string.IsNullOrEmpty(o.ItemPartNumber) ? "" : o.ItemPartNumber,

ItemRfidTag = string.IsNullOrEmpty(o.RfidTag) ? "" : o.RfidTag,

DigitalIdentity = o.DigitalIdentity,

TagType = string.IsNullOrEmpty(o.TagType) ? "" : o.TagType,

Description = string.IsNullOrEmpty(o.Description) ? "" : o.Description,

Owner = string.IsNullOrEmpty(o.Owner) ? "" : o.Owner,

ReceivingDate = o.ReceivingDate,

//Status = o.Status,

//StatusName = statusLookup.Where(s =\> s.Id == (int)o.Status)?.FirstOrDefault()?.DisplayName,

// StatusName = statusLookup?.FirstOrDefault(s =\> s.Id == (int)(o.Status ?? 0))?.DisplayName,

OriginalCost = o.OriginalCost,

InServiceDate = o.InServiceDate,

Department = string.IsNullOrEmpty(o.Department) ? "" : o.Department,

EntityName = string.IsNullOrEmpty(o.EntityName) ? "" : o.EntityName,

locationClassificationName = string.IsNullOrEmpty(o.locationClassificationName) ? "" : o.locationClassificationName,

DepreciationMethod = string.IsNullOrEmpty(o.DepreciationMethod) ? "" : o.DepreciationMethod,

DepreciationPercentage = string.IsNullOrEmpty(o.DepreciationPercentage) ? "" : o.DepreciationPercentage,

UsefulLife = string.IsNullOrEmpty(o.UsefulLife) ? "" : o.UsefulLife,

DepreciationPeriod = string.IsNullOrEmpty(o.DepreciationPeriod) ? "" : o.DepreciationPeriod,

SalvageValue = string.IsNullOrEmpty(o.SalvageValue) ? "" : o.SalvageValue,

StartDepreciationValue = string.IsNullOrEmpty(o.StartDepreciationValue) ? "" : o.StartDepreciationValue,

AssetAccount = string.IsNullOrEmpty(o.AssetAccount) ? "" : o.AssetAccount,

AccumelatedDepreciationAccount = string.IsNullOrEmpty(o.AssetAccount) ? "" : o.AccumelatedDepreciationAccount,

NetBookValue = o.NetBookValue,

DisposalReference = string.IsNullOrEmpty(o.DisposalReference) ? "" : o.DisposalReference,

DisposalDate = o.DisposalDate,

DisposalMethod = o.DisposalMethod.ToString(),

ActualSalvageValue = o.ActualSalvageValue,

Image = o.Image,

ItemImprovementPlan = o.ItemImprovementPlan,

PrintBarcodeCount = string.IsNullOrEmpty(o.PrintBarcodeCount) ? "" : o.PrintBarcodeCount,

PrintQRCodeCount = string.IsNullOrEmpty(o.PrintQRCodeCount) ? "" : o.PrintQRCodeCount,

EffectiveDate = string.IsNullOrEmpty(o.EffectiveDate.ToString()) ? "" : o.EffectiveDate.ToString(),

EffectiveDateType = o.EffectiveDateType == 1 ? "InServiceDate" : "PurchasingDate",

DepreciationExpense = itemSerialDepreciationList.Any() ? itemSerialDepreciationList.Where(i =\> i.ItemSerialSerialValue == o.SerialValue)?.LastOrDefault()?.ItemSerialDepreciation?.ExpenseValue.ToString() : "",

Reason = string.IsNullOrEmpty(o.Reason) ? "" : o.Reason,

Filed1 = string.IsNullOrEmpty(o.Filed1) ? ""  : o.Filed1,

Filed2 = string.IsNullOrEmpty(o.Filed2) ? "" : o.Filed2,

Filed3 = string.IsNullOrEmpty(o.Filed3) ? "" : o.Filed3,

LocationGroup = o.LocationGroupId != null ? locationGroups.Where(b =\> b.Id == (int)o.LocationGroupId).LastOrDefault().NameEnglish : "",

PurchaseDate = string.IsNullOrEmpty(o.PurchaseDate.ToString()) ? "" : o.PurchaseDate.ToString(),

DisposalField1 = !string.IsNullOrEmpty(o.DisposalField1) ? o.DisposalField1 : "",

DisposalField2 = !string.IsNullOrEmpty(o.DisposalField2) ? o.DisposalField2 : "",

DisposalField3 = !string.IsNullOrEmpty(o.DisposalField3) ? o.DisposalField3 : "",

DisposalNotes = !string.IsNullOrEmpty(o.DisposalNotes) ? o.DisposalNotes : "",

OpeningNetbookValue = string.IsNullOrEmpty(o.OpeningNetbookValue.ToString()) ? o.OpeningNetbookValue.ToString() : "",

UsefulLifeValue = string.IsNullOrEmpty(o.UsefulLifeValue.ToString()) ? o.UsefulLifeValue.ToString() : "",

IsCalculateDeprecition = o.IsCalculateDeprecition != null && (bool)o.IsCalculateDeprecition ? "True" : "False",

AuditUser = o.UserId != null ? \_userRepository.FirstOrDefaultAsync(long.Parse(o.UserId.ToString()))?.Result?.Name : ""

},

VendorName = string.IsNullOrEmpty(o.VendorName) ? o.VendorName : "",

ItemPartNumber = string.IsNullOrEmpty(o.ItemPartNumber) ? o.ItemPartNumber : "",

ItemLocationName = string.IsNullOrEmpty(o.ItemLocationName) ? o.ItemLocationName : "",

LocationClassificationId = o.LocationClassificationId,

LocationClassificationName = string.IsNullOrEmpty(o.Name) ? o.Name : "",

LocationClassificationFullPath = string.IsNullOrEmpty(o.FullPath) ? o.FullPath : "",

LocationClassificationLevel = o.Level,

RfidTagType = string.IsNullOrEmpty(o.RfidTagType.ToString()) ? o.RfidTagType.ToString() : "",

CountingType = string.IsNullOrEmpty(o.CountingType) ? o.CountingType : ""

};
Я получаю сообщение «Объект, допускающий значение NULL, должен иметь значение. ? но знаю точный номер строки:
Любая помощь приветствуется?»

Подробнее здесь: https://stackoverflow.com/questions/798 ... ve-a-value
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»