DapperPlusContext options.Log does not work without .Entity().
VictorioBerra opened this issue · 3 comments
Description
This does not work:
var context = new DapperPlusContext(connection);
context.UseBulkOptions(options => options.Log = s => Console.WriteLine("Bulk progress..."));
It only works if used like this:
context
.Entity<Invoice>()
.UseBulkOptions(options => options.Log = s => Console.WriteLine("Bulk progress...")) // This works!
.Identity(x => x.InvoiceID, true);
Exception
If you are seeing an exception, include the full exceptions details (message and stack trace).
Exception message:
Stack trace:
Fiddle
Fiddle - https://dotnetfiddle.net/fbTZm2
Or provide a project/solution that we can run to reproduce the issue.
- Make sure the project compile
- Make sure to provide only the code that is required to reproduce the issue, not the whole project
- You can send private code here: info@zzzprojects.com
Otherwise, make sure to include as much information as possible to help our team to reproduce the issue.
Note: More information you provide, faster we can implement a solution.
Further technical details
- Dapper version:
- Dapper Plus version:
- Database Provider:
Hello @VictorioBerra ,
This one is really not obvious,
The UseBulkOptions
work like a deferred method such as .Where
in LINQ. It will only apply to bulk operations that will follow it and not to any bulk operations that will be executed in the context.
For example, here is a working example:
context.UseBulkOptions(options => options.Log = s => Console.WriteLine("Bulk progress...")).BulkInsert(invoices);
We did it this way as a different bulk operation could require different bulk options.
Let me know if that explains correctly the cause and solution of this issue.
Best Regards,
Jon
@JonathanMagnan One last question on this, does other methods follow that same logic?
IE .Identity
and .Key
and .MapValue
works work like a deferred method such as .Where
, or is this only for .UseBulkOptions
?
Hello @VictorioBerra ,
Only UseBulkOptions
Other methods used for mappings such as Identity
and Key
already set the configuration. So you can either chain or not as you wish.