私のテーブルPersons
には、という名前の生年月日列がありますDOB
。
私の dbml ファイルに、single
という名前の追加のプロパティを追加しましたAge
。
Age
Linq クエリで、今日の ad から計算された年齢を返すにはどうすればよいDOB
ですか? つまり、以下の架空のコードのようなものを実現するにはどうすればよいですか。
DataClasses1 db = new DataClasses1();
var pp = from p in db.Persons
select new Person()
{
Name = p.Name, // ... clone all the other properties ...
Age = (DateTime.Today-p.DOB).Days/365
}
同じ目的を達成する別の方法はありますか?
ありがとう。