You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
public sealed class ReserveCostGroupEnum : SmartEnum<ReserveCostGroupEnum, string>
{
public static readonly ReserveCostGroupEnum None = new ReserveCostGroupEnum(nameof(None), "None");
public static readonly ReserveCostGroupEnum Buildings = new ReserveCostGroupEnum(nameof(Buildings), "Buildings");
public static readonly ReserveCostGroupEnum Contents = new ReserveCostGroupEnum(nameof(Contents), "Contents");
public static readonly ReserveCostGroupEnum Expenses = new ReserveCostGroupEnum(nameof(Expenses), "Expenses");
public static readonly ReserveCostGroupEnum SubContractor = new ReserveCostGroupEnum(nameof(SubContractor), "SubContractor");
public static readonly ReserveCostGroupEnum Costs = new ReserveCostGroupEnum(nameof(Costs), "Costs");
public ReserveCostGroupEnum(string name, string value) : base(name, value)
{
}
}
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
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!
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: