linq2db / linq2db.EntityFrameworkCore

Bring power of Linq To DB to Entity Framework Core projects
MIT License
459 stars 38 forks source link

Setting `BulkCopyOptions` #369

Open AntonC9018 opened 10 months ago

AntonC9018 commented 10 months ago

There doesn't seem to be a way to set BulkCopyTimeout for example, on the whole context, rather than per operation, non-globally. The only way to configure it seems to be setting a value for LinqToDBOptionsExtension on EF Core's IDbContextOptions, which seems to be the responsibility of UseLinqToDB. Anyway, I suggest adding a configuration parameter to CreateLinqToDbContext for DataOptions to make configuration like that possible.

MaceWindu commented 10 months ago

DataOptions already support bulk copy settings:

dataOptions.UseBulkCopyTimeout(123);
// or
dataOptions.BulkCopyOptions.WithBulkCopyTimeout(123);
AntonC9018 commented 10 months ago

DataOptions already support bulk copy settings:

dataOptions.UseBulkCopyTimeout(123);
// or
dataOptions.BulkCopyOptions.WithBulkCopyTimeout(123);

Well yeah, but that doesn't actually change it. You have to reassign the options after. And you can't reassign it for IDataContext.

Those methods are pure.

MaceWindu commented 10 months ago

You are not supposed to re-assign it. Check AddCustomOptions configuration extension example in readme

AntonC9018 commented 10 months ago

You are not supposed to re-assign it. Check AddCustomOptions configuration extension example in readme

Like I mentioned, that's global, aka per context type. It doesn't allow configuring it per context instance. That's what I said in this issue.

MaceWindu commented 10 months ago

I see, we can add configuration delegete parameter to CreateLinqToDbContext APIs