Mic Got

Mic Got

  • 1.6k
  • 100
  • 8k

retrieve data error

Jun 12 2023 5:36 PM

Hi,

I have this code where on the filed "UnitPrice" i try to retrieve a value from a table.

code:

var destinationRecord = new DepartmentCopy

            {
                DepartmentCopyId = sourceRecord.DepartmentId,
                Name = sourceRecord.Name,
                GroupName = sourceRecord.GroupName,
                ModifiedDate = sourceRecord.ModifiedDate,
                PurchaseOrderDetailId = sourceRecord.PurchaseOrderDetailId,

------ error here -----------------------

                UnitPrice = _dbContext.GetUnitPrice(sourceRecord.PurchaseOrderDetailId),

--------------------------------------------
            };

the field PurchaseOrderDetailId is an integer and so the code where i try to retrieve the value:

code:

public PurchaseOrderDetail? GetUnitPrice(int id)
        {
            return (from o in PurchaseOrderDetails
                    where o.PurchaseOrderDetailId == id
                    select o).FirstOrDefault();

        }

but the compiler go in error with the argument : cannot convert from int? to int

..where i'm wrong?

thks to everyone


Answers (4)