You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It basically adds an Upload overload to accept a predicate to allow for updating records based on something other than their key: Task<bool> UpdateAsync<T>(this IDbConnection connection, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = true)
The primary use case would be when you don't know the database key for a record that you want to update, but you do know some other unique identifier (for example if you're consuming from an external system and the external system includes a unique value etc).
This could be used as a building block for an upsert operation, or it could be extended to PartialUpdate to allow for bulk updating rows (eg set IsOverdue = true where PaymentDueDate < Today).
Things to note:
ignoreAllKeyProperties is defaulted to true (the assumption being that you don't know the keys, so you don't want to change them)
The return type is bool (in line with the other update methods), but I think it would be better to be an int in case you want to know how many records were updated
The text was updated successfully, but these errors were encountered:
Before I go ahead and add unit tests etc, I'd like to check that you'd accept a contribution like this: https://github.com/tmsmith/Dapper-Extensions/compare/master...paynecrl97:Dapper-Extensions:predicateUpdate?expand=1
It basically adds an
Upload
overload to accept a predicate to allow for updating records based on something other than their key:Task<bool> UpdateAsync<T>(this IDbConnection connection, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = true)
The primary use case would be when you don't know the database key for a record that you want to update, but you do know some other unique identifier (for example if you're consuming from an external system and the external system includes a unique value etc).
This could be used as a building block for an upsert operation, or it could be extended to
PartialUpdate
to allow for bulk updating rows (eg set IsOverdue = true where PaymentDueDate < Today).Things to note:
ignoreAllKeyProperties
is defaulted totrue
(the assumption being that you don't know the keys, so you don't want to change them)bool
(in line with the other update methods), but I think it would be better to be anint
in case you want to know how many records were updatedThe text was updated successfully, but these errors were encountered: