UpdateAdd issue in v.10

Hey, In my application, I have a piece of code similar to the following:

public Task UpdateSomeFieldsAsync(int entityId)
{
    using var db = await dbConnectionFactory.OpenDbConnectionAsync();

    await db.UpdateAddAsync(
    () => new Entity1 { Count = 5 }, where: p => p.Id == entityId);

    await db.UpdateAddAsync(
    () => new Entity2 { Count = 5 }, where: p => p.Entity1Id == entityId);
}

This works correctly in version 8, but after upgrading to version 10 (10.0.6), I receive the following exception on the second call to UpdateOnlyFieldsAsync:

Unable to cast object of type ‘System.Func`1[Models.Data.Entity1]’ to type ‘System.Func`1[Models.Data.Entity2]’.

Is there something that needs to be changed in my code for the newer version, or could this be a bug in the library?

Can you provide a stand-alone project, I can run to repro the issue.

While I’m still working on building a reproducible example using UpdateOnlyFields, I was able to reproduce the issue using the UpdateAdd function. Here is a project that demonstrates the problem

Thanks, it should be resolved in this commit.

This change is available from v10.0.7 which is now available in the pre-release packages.

Thanks, @mythz. I appreciate it and look forward to the release of version 10.0.7.

1 Like