-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EF Core 7 InMemory - Throwing System.ArgumentException with any query involving a SmartEnum #400
Comments
Can you share what version(s) of EF Core and SmartEnum libraries you're on? I know you said latest but just confirming so I can reproduce with the same stuff you have. Thanks! |
Yeah no worries: Ardalis.SmartEnum 7.0.0 Thanks for taking a look! |
Dug into it a bit more today and the issue seems to only happen when checking for null using operators, it works fine when using '.Equals'.
This works fine, however
bombs out with 'System.ArgumentException'. (sorry, I know this is different to my original example!) |
Upgrading my solution to .NET 7 and suddenly hitting the following exception when running unit tests:
System.ArgumentException : Expression of type 'Ardalis.SmartEnum.SmartEnum'2[Namespace.ReserveCostGroupEnum,System.String]' cannot be used for parameter of type 'System.String' of method 'Namespace.ReserveCostGroupEnum GetFromValue(System.String)' (Parameter 'arg0')
Unsure if the problem lies with the Microsoft.EntityFrameworkCore.InMemory package or SmartEnum.
I am not getting the issue running through SQL server, only through unit tests using an InMemory db.
Tried applying the Conversion through:
and
builder.Property(p => p.ReserveCostGroup).HasColumnType("varchar(20)").HasConversion(p => p.Value, p => ReserveCostGroupEnum.FromValue(p));
I've upgraded all the SmartEnum packages to the newest available.
An example of a simple query that fails:
var enumTest = await dbContext.Test_Table.Where(q => q.ReserveCostGroup == ReserveCostGroupEnum.SubContractor).ToListAsync()
an example of the SmartEnum:
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: