Loading

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
}

 

posted @ 2014-07-30 18:34  Dhoopu  阅读(292)  评论(0编辑  收藏  举报