Closed milannankov closed 4 years ago
@ajcvickers https://github.com/dotnet/efcore/blob/master/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs#L143-L146
Should be?
_partitionKeyValueConverter = partitionKeyProperty.FindTypeMapping()?.Converter
?? partitionKeyProperty.GetValueConverter();
This code needs to be in core and more first class (Probably just be part of ValueConverter) https://github.com/dotnet/efcore/blob/98a231faefb919421cfbe50109a2aa59e1dc12c1/src/EFCore.Relational/Storage/RelationalTypeMapping.cs#L453-L457
Is there a workaround on the framework level that can be used? There is nothing that I could think of besides making temporary changes to classes and directly use int instead of an Enum.
I am using the EF Core Azure Cosmos DB Provider and trying to execute a query where I filter based on an enum value but I am getting "'Invalid cast from 'System.Int32' to 'efcore_cosmosdb_bug.OperationStatus'.'" error.
The problem is caused by the Status property of the class InitOperation. There is also a conversion specified in the context but it does not seem to be helping.
The code that breaks is the following:
Steps to reproduce
efcore-cosmosdb-bug.zip
I have attached a project that demostrates the problem. Just run the CosmosDb emulator, add the connection settings and run the program.
Further technical details
EF Core version: 3.1.3 Database provider: 3.1.3 Target framework: .NET Core 3.1 Operating system: Windows 7 IDE: Visual Studio Code