誰かがそれをlinqからsqlに変換して、どういうわけかletを削除できますか?
Func<string, DateTime?> tryToGetDate = value =>
{
DateTime dateValue;
return DateTime.TryParse(value, out dateValue)
? (DateTime?)dateValue
: null;
};
var dates = (from bk in _context.BookDetails
join bkcategories in _context.BookCategories
on bk.BookId equals bkcategories.BookId
where bkcategories.CategoryId == Convert.ToInt64(categoryid)
let dateValue = tryToGetDate(bk.PublishedDate)
where dateValue != null && (DateTime)dateValue >= twomonths && (DateTime)dateValue <= today
orderby bk.PublishedDate descending, bk.BookId
select bk).Take(2).ToList();