Quantcast
Channel: C# Entity Framework, Get Inserted ID (Generic) - Stack Overflow
Browsing latest articles
Browse All 2 View Live

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 Article



C# 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
Browsing latest articles
Browse All 2 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>