LINQ TO ENTITY 根据Birthday获取Age

from emp in EmployeeInfo
let years = EntityFunctions.DiffYears(emp.Birthday.Value,DateTime.Now)
let birthdayThisYear = EntityFunctions.AddYears(emp.Birthday.Value,years)
select new 
{
   Age = birthdayThisYear > DateTime.Now ? years - 1 : years
}
原文地址:https://www.cnblogs.com/dupeng0811/p/3878754.html