Search code examples
c#databasesimple.data

Update field using same field as key with Simple.Data


I want to achieve this:

UPDATE MyTable SET Field1=Field1 + 1 WHERE Field2 = 1 AND Field1 = 5000

Just to explain why is that im verifying that nobody else touched the record, Field1 is a sequence number.

How to achieve this, im thinking something like. MyDb.MySchema.Table.UpdateByField1AndField2(Field1: 5000, Field2: 1, Field1: 5001). Obviously this does not work.


Solution

  • what about ...

    MyDb.MySchema.Table.UpdateAll(Field1: 5001, Condition: MyDb.MySchema.Table.Field1==5000 && MyDb.MySchema.Table.Field2==1)
    

    ?