Here is my SQL query. I'm trying to produce the same results in my .NET Core web app using a linq query.
SELECT *
FROM dbo.BUD
WHERE LEFT(PeriodD, 4) = YEAR(GETDATE())
Here is what I've tried with no success in my linq query
List<SelectListItem> budNames = _ctx.Budgets.AsNoTracking()
.Where(n => (n.Period, 4) == GETDATE())
.Select(n => new SelectListItem
{
// values
}).ToList();
YEAR(GETDATE())- otherwise, you're comparing to one specific moment in time - not a whole yeaR!