I am using C# drivers and I was using LinqV3 explicitly, after updating to 2.19 I started getting an error for conversion that worked previously:
var projection = Projection.Expression(x =>
new LowOxygenPerTemperatureStateResponseData
{
UnitState = ((LowOxygenPerTemperatureRuleStateData) x.State!).Units[stringSiteId][stringUnitId], // ! is required here since it is an expression, it can be null, but this will not fail since it is an expression
UnitEventValues = ((LowOxygenPerTemperatureRuleEventValuesData) x.EventValues!).SiteUnits[stringSiteId][stringUnitId] // ! is required here since it is an expression, it should never be null in response as we are updating this exact field
});
I am then doing this operation:
await Collection.FindOneAndUpdateAsync(
filter,
update,
new FindOneAndUpdateOptions<BusinessRuleInformationData, TProjection>
{
ReturnDocument = returnDocument,
Projection = projection
});
I already had to create filter and update using a string path, but I cannot find out how can I do the same for projection, since I need a C# class back that will be of a given type.
So what I need is to generate a path for return and that path would be different depending on the data that is stored and thus I need to do a cast in C# since e.g. Units does not exist on a base class, but it seems to have stopped working after the update.
How can I resolve this issue?