Incrementing Partial Keys

Posts   
 
    
dioptre
User
Posts: 66
Joined: 29-Mar-2007
# Posted on: 17-Oct-2008 09:25:13   

I am trying to increment a revision of a stored document ie. if this is stored documentid = 1 documentversion = 1

i'm trying to generate a new documentversion for the next one to go in I know i can do this with scalar queries (which i've done before), but that's rubbish - it requires a round-trip

ie i want to insert: documentid, max(documentversion) + 1, for a predicated documentid

what's wrong with this?


IExpression revisionExpressionIncrement = new Expression(DocumentCacheFields.DocumentVersion, ExOp.Add, 1);
IExpression revisionExpression = new ScalarQueryExpression(DocumentCacheFields.DocumentVersion.SetAggregateFunction(AggregateFunction.Max).SetExpression(revisionExpressionIncrement), (DocumentCacheFields.DocumentId == docEntity.DocumentId));
docCacheEntity.Fields[(int)DocumentCacheFieldIndex.DocumentVersion].ExpressionToApply = revisionExpression;

cheers! andrew