我有一個方法:僅在部分代理的LINQ中有兩種方法不同?
internal List<int> GetOldDoctorsIDs
{
var Result = from DataRow doctor in DoctorTable.Rows
where doctor.Age > 30
select doctor.ID
List<int> Doctors = new List<int>();
foreach (int id in Result)
{
//Register getting data
Database.LogAccess("GetOldDoctorsID: " + id.ToString());
if (Database.AllowAccess(DoctorsTable, id))
{
Doctors.Add(id);
}
}
}
所以這個變老醫生和做其他的事情。現在我想創建方法GetExpensiveDoctors。它看起來像這上面,但代替:
where doctor.Age > 30
我將有:
where doctor.Cost > 30000
如何爲此創造優雅,面向對象的解決方案嗎? 我應該使用委託還是其他的東西?
這就是我建議的Func,其中TReturn的類型是bool,相當於Predicate 。 –
2009-12-14 11:13:02
是的,所以我也給了你一個觀點 – 2009-12-16 10:38:01