/ / Ako používať hromadné vloženie v rámci Entity Framework pomocou objektového kontextu? - c #, asp.net-mvc, entity-framework, linq-to-entities, entity-framework-6

Ako používať hromadné vloženie v rámci Entity Framework pomocou kontextu objektov? - c #, asp.net-mvc, entity-framework, linq-to-entities, entity-framework-6

Rád by som namiesto DbContext použil Object Context na volanie Bulk Insert v Entity Framework 6. Ako to môžem urobiť?

Chcel by som niečo urobiť

iba na čítanie ObjectContext obContext:

public void BulkInsert<T>(IEnumerable<T> items) where T : class, new()
{
obContext.BulkInsert(items);
}

Ale nemôžem to urobiť.

odpovede:

1 pre odpoveď č. 1

S rámcom entity 6 môžete použiť tento pekný balík nuget na hromadné vloženie a môžete ho použiť s objektom DbContext.

tak niečo takéto:

using (var db = new YourDbContext())
{
EFBatchOperation.For(db, db.BlogPosts).InsertAll(list);
}

https://github.com/MikaelEliasson/EntityFramework.Utilities

Dúfam, že to pomôže.