Ein Repository-Factory-Klasse

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 zu schaffen, eine RepositoryFactory Klasse und ich habe kopiert, was ich bisher getan habe. Könnte jemand bitte helfen Sie mir, um dies herauszufinden ? Ich bin stecken !
Vielen Dank im Voraus

edit :

Ich soll sowas am Ende. Ist es möglich, 1 Repository-Klasse und implementieren so etwas wie

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();
        }
    }

InformationsquelleAutor der Frage Kubi | 2011-01-12

Schreibe einen Kommentar