var clientsdata = (from c in _dataContext.Clients
join ao in _dataContext.AccountOwners on c.AccountOwnerID equals ao.AccountOwnerID
join at in _dataContext.AccountTypes on c.AccountTypeID equals at.AccountTypeID
where c.IsActive == true && (c.IsDeleted == false || c.IsDeleted == null) && c.AccountExpiryDate > DateTime.Now && (GetdayValue(c.AccountExpiryDate) >= getMondayValue(c.AccountExpiryDate, true) && GetdayValue(c.AccountExpiryDate) <= getMondayValue(c.AccountExpiryDate, false))
select new EntClient
{
Clientid = c.ClientID,
ClientEmail = c.ClientEmail,
ClientName = c.ClientName,
AccountOwnerName = ao.AccountOwnerName,
AccountOwnerID = ao.AccountOwnerID,
AccountTypeID = at.AccountTypeID,
AccountExpiryDate = c.AccountExpiryDate,
CurrentPlanPricePerMonth = at.PricePerMonth
//acc
}).ToList();
public DateTime getMondayValue(DateTime? dayVal, bool isLastMonday)
{
DateTime temp = DateTime.Now;
if (dayVal == null)
return temp;
temp = dayVal.Value;
if (isLastMonday)
temp = DateTime.Now.AddDays(-(DateTime.Today.DayOfWeek - DayOfWeek.Monday - 7));
else
temp = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek).AddDays((int)DayOfWeek.Monday);
return temp;
}
public DateTime GetdayValue(DateTime? dayVal)
{
DateTime temp = DateTime.Now;
if (dayVal == null)
return temp;
temp = dayVal.Value;
temp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, temp.Day);
return temp;
}
)
我想将此SQL转换为linq,我正在尝试转换它,但它会抛出异常。 有人可以帮忙吗? 提前致谢