I am trying to create a drop down for NAICS codes. I have tried two ways but keep getting errors. My first method is using the "TextProperty" to look at a NotMapped property that combines the code and the definition:
// NAICSCode Entity Framework object property
[NotMapped]
public string Combined => $"{Code} : {Definition}";
// .razor
<RadzenDropDown @bind-Value=ViewModel.PrivateApplicationDTO.NAICSCode
AllowFiltering="true"
Data="ViewModel.NAICSCodes"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
TextProperty="Combined"
TValue="NAICSCode" />
This produces the following error in the Chrome Inspector:
Error: System.InvalidOperationException: The LINQ expression 'DbSet()
.Where(n => n.IsActive && n.InUse)
.Where(n => n.Combined.ToLower().Contains("c"))' could not be translated. Additional information: Translation of member 'Combined' on entity type 'NAICSCode' failed. This commonly occurs when the specified member is unmapped.
Translation of member 'Combined' on entity type 'NAICSCode' failed. This commonly occurs when the specified member is unmapped. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See Client vs. Server Evaluation - EF Core | Microsoft Learn for more information.
I have also tried the Template Method:
<RadzenDropDown @bind-Value=ViewModel.PrivateApplicationDTO.NAICSCode
AllowFiltering="true"
Data="ViewModel.NAICSCodes"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
TValue="NAICSCode">
<Template Context="code">
@((code as NAICSCode).Code) : @((code as NAICSCode).Definition)
</Template>
</RadzenDropDown>
This produces the following error in the Chrome Inspector:
Error: System.NotSupportedException: Specified method is not supported
The Question: How can I use the filter where two properties of an object is used as the Text Property and search on both properties?
Thank you in advance for any help.