I am looking to be able to load an entity by ID using generics and property reflection but am unsure how to accomplish this task using Entity Framework 4.0.
I have a method in my abstract method as such:
public abstract T GetById(object id, TestContext context);
Currently, since it is abstract, I have to implement this method in every single repository class I create as such:
public override TestObject GetById(object id, TestContext context)
{
return context.TestObject.First(x => x.TestId == (int) id);
}
Is there a way to accomplish this same task using reflection and generics in my abstract class?