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
I want to filter for a property that is declared on a derived class. But the IQueryable is defined as the base class.
Unfortunatly, I cannot figure out how to cast the elements to the derived class. I tried the casting as suggested in this issue, but it does not work for me: #452 (comment).
I would like to avoid the 'CustomTypeProvider' and I have no issue with fully qualify the type names.
2. Fiddle or Project
Heres my attempt of casting...
usingConsoleApp1.App.Foo.Bar;usingSystem.Linq.Dynamic.Core;// Holds a mix of derivatives of 'BaseEntity'varquery=Enumerable.Empty<BaseEntity>().AsQueryable();// This is what I want to generate :)query.Where(e =>((SpecialEntity)e).Name=="Okay");// Thats my attempt of casting...varfilter=$"{typeof(SpecialEntity)}(it).Name == \"Okay\"";Console.WriteLine(filter);query.Where(filter);Console.WriteLine("Done!");Console.ReadKey();namespaceConsoleApp1.App.Foo.Bar{publicclassBaseEntity{publicrequiredintId{get;set;}}publicclassSpecialEntity:BaseEntity{publicrequiredstringName{get;set;}}}
The text was updated successfully, but these errors were encountered:
1. Description
I want to filter for a property that is declared on a derived class. But the IQueryable is defined as the base class.
Unfortunatly, I cannot figure out how to cast the elements to the derived class. I tried the casting as suggested in this issue, but it does not work for me: #452 (comment).
I would like to avoid the 'CustomTypeProvider' and I have no issue with fully qualify the type names.
2. Fiddle or Project
Heres my attempt of casting...
The text was updated successfully, but these errors were encountered: