Witam,
zauważyłem że w moim dao jest kilka metod podobny do siebie, które różnią się od siebie jedynie wyrażeniem where np
class DAO{
public getDocumentIsReadyList(){
using(var db = new MigContex()){
var model = ( from d in db.Document
where d.IsReady == true
select d).ToList()
return model;
}
}
public getDocumentList(){
using(var db = new MigContex()){
var model = ( from d in db.Document
select d).ToList()
return model;
}
public getDocumentToPrepare(){
using(var db = new MigContex()){
var model = ( from d in db.Document
where d.transferDate != null
select d).ToList()
return model;
}
}
Class A {
List<Document> getDocument (DocumentType type) {
switch(type)
case DocumentType.All:
return dao.getDocumentList();
case DocumentType.ToPrepare:
return dao.getDocumentIsReadyList();
case DocumentType.IsReady:
return dao.getDocumentToPrepare();
}
}
Czy da się to jakoś uprościć ?