I am using Entity Frame work as an ORM and i want to have a single generic method for inserting different entities. say for example i have two entities foo
and bar
and i am currently adding them like
internal void Add(Foo _foo){ dbContext.Foo.AddObject(_foo); }
and for bar
internal void Add(Bar _bar){ dbContext.Bar.AddObject(_bar); }
i am finding it difficult to wrap my head around the generics. Please help me in writing a generic method for inserting typeOf entities. Plus if somebody guide me to a beginner level tutorial i'll greatful.