Sir Thomas - 389 - Oct 24, 2014

Any chance UpdateAll<T> could be extended to also offer “only fields” options that are in the UpdateOnly<T>?

I would like to frequently update only specific fields on a list of objects, and thought it could benefit ORMLite to offer this, instead of ForEach’ing the UpdateOnly<T> which incurs multiple db round-trips.

Thanks!

UpdateAll still incurs multiple DB hits, each updated item can have different values to be updated, i.e. it’s not a single update query that updates all elements. 

Also you wouldn’t be extending the existing UpdateAll method which from an API convention doesn’t fit, it would likely need to be UpdateOnlyAll(). Although UpdateOnly already offers an override that accepts where: expression which can already be used to update multiple items in a single statement. 

Do you have a concrete example usage for the proposed API? I’m curious if this is something that can be updated in a single statement or it’s just going to be a wrapper that foreach’s over UpdateOnly.

Sir Thomas:

sorry for delay - was out of town.

I had assumed that UpdateAll was generating a combo SQL statement that would update each record with each value.  If it foreach’s through the list of items, then not much difference to do it client side I guess.

As for an example, let’s say I have in memory an array of players and I want to update all players’ points property.  (can’t update all players directly because other APIs might have updated the Name, Nickname, etc. fields.).

So, would be something like:

Db.UpdateAll(playerList, “points”)

(“points” is probably an EV with the field list that matches the definition signature of UpdateOnly)