I will have several “types” of the object, and I'm really not sure how best to retrieve / save these several types without separately saving / retrieving for each type.
My classes:
public class Evaluation {
public int Id
public string Comment
}
public class EvaluationType_1 : Evaluation {
public string field
}
public class EvaluationType_1 : Evaluation {
public string field
}
What I would like to do in my repository:
public interface IEvaluationRepository {
public Evaluation getEvaluation(int id);
public SaveEvaluation(Evaluation);
}
Inside the get / save methods:
Id
Comments
Type childType = ???
switch(childType) {
}
Hope this makes sense. I would prefer not to add the "type" column, as I have this in another part of my database, and I don't like it very much.
UPDATE
Great comments, everyone - thank you very much. Here is additional information / questions for clarification, if necessary.
I like the idea of using interfaces and generics, I really don’t understand how to include them in my repository template.
getEvaluation, , , . - - !
2
, , : P.
: Id (PK)
EvaluationType1
Id (FK to Evaluations.Id)
Field
EvaluationType1
Id (FK to Evaluations.Id)
Field
, getEvaluation(int id) , . , ? saveEvaluation, switch/function, , Type.