Setting a Column = Column + Value

Posts   
 
    
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 19-Nov-2009 11:52:30   

How can I achieve the following:

  RelationPredicateBucket predicate = new RelationPredicateBucket();
        predicate.PredicateExpression.Add(PlayerSessionFields.PlayerSessionId == ssoDTO.PlayerSessionId);
        PlayerSessionEntity sessionEntity = new PlayerSessionEntity();
//required bit  ...
sessionEntity.GameCount++;
//end required bit...
  using (DataAccessAdapter adapter = new DataAccessAdapter())
        {
          int numUpdated = adapter.UpdateEntitiesDirectly(sessionEntity, predicate);
        }


So the SQL i would want is:

update playersession set gamecount=gamecount+@amount where ...

I do not want to load the entity and do

update playersession set gamecount=@gamecount

because of concurrency etc.

thanks

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 19-Nov-2009 12:31:07   

You should use an expression as explained here.