DB から Customers のデータ アクセス関数を作成する次のクラスがあります。
public static Customer Get(int ID)
{
KezberPMDBDataContext db = new KezberPMDBDataContext();
return (from p in db.Customers
where p.CustomerID == ID
select p).FirstOrDefault();
}
public static bool Remove(int ID)
{
Customer c = Get(ID);
if (c != null)
{
KezberPMDBDataContext db = new KezberPMDBDataContext();
db.Customers.DeleteOnSubmit(c);
db.SubmitChanges();
return true;
}
return false;
}
Employee クラスだけを使用して、まったく同じ機能を必要とする、Employees などのクラスをさらに作成します。
コードの重複を回避し、何らかの方法でテンプレート/ジェネリックを使用する方法はありますか?
ありがとう