I have the following code using Dapper.SimpleCRUD :
var test = new FallEnvironmentalCondition[] {
new FallEnvironmentalCondition {Id=40,FallId=3,Environm
MARS has some limitations and also a non-zero overhead. You can use the following helpers to make the updates sequential:
public static async Task WhenAllOneByOne(this IEnumerable source, Func process)
{
foreach (var item in source)
await process(item);
}
public static async Task> WhenAllOneByOne(this IEnumerable source, Func> transform)
{
var results = new List();
foreach (var item in source)
results.Add(await transform(item));
return results;
// I would use yield return but unfortunately it is not supported in async methods
}
So your example would turn into
await test.WhenAllOneByOne(conn.UpdateAsync);
I usually call the second helper instead of Task.WhenAll, as follows:
await Task.WhenAll(source.Select(transform)); // not MARS-safe
await source.WhenAllOneByOne(transform); // MARS-safe