Basit Nisar

Basit Nisar

  • 1.7k
  • 84
  • 11.1k

How to retrieve value of Property in a model using Stored Proc

Mar 10 2023 2:02 PM
select (new TimeSheetDetailViewModel
{
    TimeCardID = timecard.TimeCardID,
    TimeSheetStatusTypeID = timecard.StatusID ?? 0,
    TimeSheetStatusTypeName = BC.TimeSheetStatusTypeName,
    SubmittedDate = timecard.SubmittedDate,
    HourWorks = timecard.MinutesWorked,
    ContactID = timecard.ContactID,
    FirstName = contact.FirstName.Trim(),
    MiddleName = contact.MiddleName,
    LastName = contact.LastName,
    EmployeeNumber = contact.EmployeeNumber,
    WeekStartDate = timecard.WeekStartDate,
    WeekEndDate = DbFunctions.AddDays(timecard.WeekStartDate, 6),
    ApprovedBy = timecard.ApprovedBy,
    ApprovedDate = timecard.ApprovedDate,
    CATStaffApprovedBy = timecard.CATStaffApprovedBy,
    CATStaffApprovedDate = timecard.CATStaffApprovedDate,
    RejectionComment = contextTimesheet.TCRejectionHistories.OrderByDescending(t => t.RejectionHistoryID).FirstOrDefault(t => t.TimeCardId == timecard.TimeCardID).Comment ?? string.Empty,
    PayTypeID = timecard.PayTypeId ?? 0,
    PayTypeName = BC.PayTypeName,
    DiemTypeID = BC.DiemTypeID ?? 0,
    DiemTypeName = BC.DiemTypeName ?? "",
    ContactAssignmentID = CA.ContactAssignmentID,
    LastModifiedDate = this.Database.("EXEC [dbo].[spGetTimecardLastModifiedDate] @TimeCardID, @InvoiceSourceTypeID").FirstOrDefault()
}
)).Distinct().ToList<TimeSheetDetailViewModel>();

 


Answers (1)