EntityFramework-Extensions
EntityFramework-Extensions copied to clipboard
BulkUpdate rows affected
It would be useful if BulkUpdate returned the count of rows affected. Same for other methods where it makes sense.
Hello @PhilPJL ,
Thank you for reporting.
We already looked at it in the past so I cannot guarantee you anything. Due to some options, it makes it for us sometimes very hard to get the real number of row affected.
However, for most basic options, we should probably do something and have this value.
Could you tell me which database provider you are using?
Best Regards,
Jonathan
I'm using SQL Server. I replaced a batch update statement with BulkUpdate and it does seem to be faster. The issue is that using a batch update I can do rowsAffected = context.Database.ExecuteSqlCommand
and then abort if the value isn't correct, with BulkUpdate I can't.
I know this is old, but it seems still relevant. In SQL Server at least, you can output $action then group to get counts, but I suppose you want to handle other providers too. Maybe it just needs to work when the underlying provider supports it. That's just how it is when you create abstraction layers!
Hello all,
Sorry for the delay, the library added that features a few months ago (stating from v3.0.66): https://github.com/zzzprojects/EntityFramework-Extensions/releases/tag/3.0.66
By using the UseRowsAffected = true
options, the performance will slightly be decreased however, you will be able to get access to the RowsAffected:
- RowsAffected
- RowsAffectedInserted
- RowsAffectedUpdated
- RowsAffectedDeleted
That's awesome! I hope to give this a try over the next few days.
Perfect! Works like a charm. I couldn't find any documentation on it though so I didn't know it was there. Maybe I missed it?
Oops sorry I forget to answer you,
You are right, we added recently a light documentation on this option: https://entityframework-extensions.net/rows-affected
Thanks! That looks good and is very helpful.