=== Snippet 3: Fallible database operations ===
(ProcedureContext ctx, uint a, string b)
| 31 | |
| 32 | // === Snippet 3: Fallible database operations === |
| 33 | [SpacetimeDB.Procedure] |
| 34 | public static void MaybeInsertAValue(ProcedureContext ctx, uint a, string b) |
| 35 | { |
| 36 | ctx.WithTx(txCtx => |
| 37 | { |
| 38 | if (a < 10) |
| 39 | { |
| 40 | throw new Exception("a is less than 10!"); |
| 41 | } |
| 42 | txCtx.Db.MyTable.Insert(new MyTable { A = a, B = b }); |
| 43 | return 0; |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | // === Snippet 4: Reading values out of the database === |
| 48 | [SpacetimeDB.Table(Accessor = "Player")] |