4
Answers

retrieve data error

Mic Got

Mic Got

1y
574
1

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)