I'm trying to calculate the hours that fall during the week at a different rate than the ones worked during the weekend. This is how I was hoping to accomplish it:
private void SetTotalCharge()
{
int.TryParse(MDate.ToString("MM"), out int month);
int.TryParse(MDate.ToString("yyyy"), out int year);
TotalCharge =
Decimal.Round(Convert.ToDecimal(db.MyTable
.Where(a => a.Date <= MDate & a.Date.Month == MDate.Month & (a.Date.Year) == year & (a.Date.DayOfWeek != DayOfWeek.Saturday && a.Date.DayOfWeek != DayOfWeek.Sunday))
.Select(a => a.RepairHours).Sum() * RateWeek
+ db.MyTable
.Where(a => a.Date <= MDate & a.Date.Month == MDate.Month & (a.Date.Year) == year & (a.Date.DayOfWeek == DayOfWeek.Saturday && a.Date.DayOfWeek == DayOfWeek.Sunday))
.Select(a => a.RepairHours).Sum() * RateWeekend), 2, MidpointRounding.AwayFromZero);
}
The error I'm getting:
System.NotSupportedException: "The specified type member 'DayOfWeek' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."
How can I get around this?