Hello!
I have a ragGridView setup roughly as follows:
modelBuilder.Entity<TblCustomers>(entity =>
{
...
entity.Ignore(e => e.Errors);
});
public partial class TblCustomers
{
...
[NotMapped]
public string Errors { get; set; }
}
void SetupRGV()
{
var options = new DbContextOptionsBuilder<Test_Context>();
options.UseSqlServer(GlobalState.ConnectionString);
TestContext = new Test_Context(options.Options);
var view = new QueryableEntityCoreCollectionView<TblCustomers>(TestContext, TestContext.TblCustomers, new Collection<string>() { });
rgvGrid.ItemsSource = view;
}
This works fine, loads and works as expected, and I can fill the unmapped "Errors" field as need be. However, when I click the top of the "Errors" column in the grid to sort, it throws an Exception (see below), tells me I should set up explicit client evaluation and points me at this Microsoft article: https://learn.microsoft.com/en-ca/ef/core/querying/client-eval. I get the following error:
The LINQ expression 'DbSet<TblCustomers>()
.OrderBy(t => t.Errors)' could not be translated.
Additional information: Translation of member 'Errors' on entity type 'TblCustomers' 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'.
I did try that, and tried to unmap/ignore the field outright so that it wouldn't be sent to the server, but my problem persists.
I can intercept the sorting event and just cancel it when the Errors column is touched, but I'd really prefer to be able to sort by an unmapped field. Could I intercept the filtering event instead?
Is this something that a RadGridView can do for me using that approach I'm taking, or am I simply out of my depth? If I'm just on the wrong track entirely, just let me know and I'll continue researching - no need to provide a custom solution just for this.
Thanks!
Lee