各テーブルには、多くの関数を書いています。これらを 1 つの関数に変換する必要があります。
例:テーブルごとに2つの関数があります
private void SelectByRank(int Rank)
{
DBEntities MyDB = new DBEntities();
var Query1 = from P in MyDB.Per
where P.IDRANK == Rank
select P;
}
private void SelectByRankANDBlah(int Rank, string Blah)
{
DBEntities MyDB = new DBEntities();
var Query1 = from P in MyDB.Per
where P.IDRANK == Rank && P.BLAH == Blah
select P;
}
今、私は 1 つの関数に変換します。例えば
private void Select(string strKind,int Rank, string Blah)
{
var strWhere ="";
if(strKind == "RANK")
{
strWhere = "where P.IDRANK ==" + Rank;
}
else
{
strWhere = "where P.IDRANK == " + Rank + " && P.BLAH == " + Blah;
}
DBEntities MyDB = new DBEntities();
var Query1 = from P in MyDB.Per
strWhere
select P;
}
わかった?