Answer by cadrell0 for C# Entity Framework, Get Inserted ID (Generic)
Your context has a Set<T>() method that will return the DBSet for the correct type.This will make your methodprivate int Add(T entity){ Using (BarContect db = new BarContext()) { DbSet dbSet =...
View ArticleC# Entity Framework, Get Inserted ID (Generic)
I've got a method called AddFoo(Foo foo)private int AddFoo(Foo foo){ Using (BarContext db = new BarContext()) { db.Foos.Add(foo); db.SaveChanges(); } return foo.FooID;}I'd like to make it more generic...
View Article
More Pages to Explore .....