1
var employeePayDetails = (from p in Catalog.Providers
where p.Key == providerKey
from a in p.Appointments
from e in a.Employee.Services
from l in a.Allocations
from ip in l.InvoicePayments
where (a.Employee != null && a.Created >= begin && a.Created <= end) where (e.Service.Id==l.Service.Id)
select new
{
ServiceName = l.Service,
CustomersServiced = l.Pet.Name + " " + a.Owner.LastName,
AppointmentDate = a.Created,
EmployeeName = a.Employee.Name,
PaymentOptionType = e.PaymentOption,
RateValue = e.Rate,
WorkedHours=l.End-l.Start,
PayAmount= ?
}).ToList();
在上述實體框架查詢我需要根據下文提到的開關語句來計算PayAmount。條件實體框架查詢字段
switch (PaymentOption)
{
case 1:
PayAmount= WorkedHours * RateValue ;
break;
case 2:
PayAmount = RateValue ;
break;
case 3:
PayAmount = LatestTotal ;
break;
}
所以我怎麼可能把上面switch語句價值,爲實體框架查詢爲PayAmount?
感謝您的回答。 – Sampath 2013-03-19 12:22:00