Well, my app has a service layer and a repository layer. I have service layer classes calling into repository classes that map one-to-one to the tables in my schema. I realized I was creating the same Save() and Get() methods in each repository class, only differing by the entity being returned, so I figured genericized versions I could but in my repository base class would just clean up my code.
My Save<>() below works fine, so I wanted to add them for Get() and SaveCollection() as well.
public R Save<R>(R entity, bool refetch, bool saveRecursize) where R : IEntity2
{
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.SaveEntity((IEntity2)entity, refetch, saveRecursize);
return entity;
}
}
Oh, and I also know that my PKs are always guids for one part of the schema and ints for another part, so me passing in the wrong type isn't an issue for me.
thx