| 305 | } |
| 306 | |
| 307 | [Reducer] |
| 308 | public static void test(ReducerContext ctx, TestAlias arg, TestB arg2, TestC arg3, TestF arg4) |
| 309 | { |
| 310 | Log.Info("BEGIN"); |
| 311 | Log.Info($"sender: {ctx.Sender}"); |
| 312 | Log.Info($"timestamp: {ctx.Timestamp}"); |
| 313 | Log.Info($"bar: {arg2.foo}"); |
| 314 | |
| 315 | // Handle TestC (a simple enum). |
| 316 | switch (arg3) |
| 317 | { |
| 318 | case TestC.Foo: |
| 319 | Log.Info("Foo"); |
| 320 | break; |
| 321 | case TestC.Bar: |
| 322 | Log.Info("Bar"); |
| 323 | break; |
| 324 | } |
| 325 | |
| 326 | // Handle TestF (a tagged enum). We pattern‐match on its concrete types. |
| 327 | switch (arg4) |
| 328 | { |
| 329 | case TestF.Foo _: |
| 330 | Log.Info("Foo"); |
| 331 | break; |
| 332 | case TestF.Bar _: |
| 333 | Log.Info("Bar"); |
| 334 | break; |
| 335 | case TestF.Baz fb: |
| 336 | Log.Info(fb.Baz_.value); |
| 337 | break; |
| 338 | } |
| 339 | |
| 340 | // Insert 1000 rows into the test_a table. |
| 341 | for (uint i = 0; i < 1000; i++) |
| 342 | { |
| 343 | ctx.Db.test_a.Insert(new TestA |
| 344 | { |
| 345 | x = i + arg.x, |
| 346 | y = i + arg.y, |
| 347 | z = "Yo" |
| 348 | }); |
| 349 | } |
| 350 | |
| 351 | var rowCountBeforeDelete = ctx.Db.test_a.Count; |
| 352 | Log.Info($"Row count before delete: {rowCountBeforeDelete}"); |
| 353 | |
| 354 | ulong numDeleted = 0; |
| 355 | // Delete rows using the "foo" index (from 5 up to, but not including, 10). |
| 356 | for (uint row = 5; row < 10; row++) |
| 357 | { |
| 358 | numDeleted += ctx.Db.test_a.foo.Delete(row); |
| 359 | } |
| 360 | |
| 361 | var rowCountAfterDelete = ctx.Db.test_a.Count; |
| 362 | |
| 363 | if (rowCountBeforeDelete != rowCountAfterDelete + numDeleted) |
| 364 | { |