public enum RepositoryType
{
ClinicRepository,
MedicationRepository,
PatientRepository,
TreatmentRepository
}
public class ObjectFactory<T>
{
public static IRepository<T> GetRepositoryInstance(RepositoryType type)
{
switch (type)
{
case RepositoryType.ClinicRepository:
return new what ?;
default:
return what ?
}
}
}
public interface IRepository<T>
{
void Add(T item);
void Remove(int id);
void Update(T item);
IList<T> GetAll();
T GetItemById(int id);
}
Ich versuche, eine RepositoryFactory-Klasse zu erstellen, und ich habe kopiert, was ich bisher getan habe. Könnte mir bitte jemand helfen, das herauszufinden? Ich stecke fest ! Vielen Dank im VorausEin Repository Factory-Klasse
edit:
Ich mag so etwas wie dies am Ende. Ist es möglich, 1 Repository-Klasse zu erstellen und so etwas wie
zu implementieren dc.THATOBJECT.insertonsubmit (item)?
public class TreatmentRepository : IRepository<Treatment>
{
public void Add(Treatment item)
{
using (PatientsDataContext dc = new PatientsDataContext())
{
dc.Treatments.InsertOnSubmit(item);
dc.SubmitChanges();
}
}
Was sind die Vorteile einer Repository Factory? – Oskar