Filter dynamic column with ExpressionMethod throws Exception
See original GitHub issueLinQToDb: 2.7.4 Firebird: 2.1
Hi,
is it possible to use dynamic columns with ExpressionMethods? I have the following:
[Table("PERSON")]
public class Person{
[COLUMN("AGE")]
public int Age {get; set;}
[COLUMN("NAME")]
public string Name {get; set;}
[ExpressionMethod(nameOf(GetTypeExpr), IsColumn = true)]
public int Type {get; set;}
public static Expression<Func<Person, int>> GetTypeExpr(){
return p => (Sql.Property<int>(p, "OPTIONS")& 0xF);
}
}
The table looks like this:
Tablename PERSON, Columns: AGE (int), NAME (int), OPTIONS (string)
The real context looks complexer…
This works:
using(var db = new MyDb()){
var result = db.GetTable<Person>().ToList();
}
result has all Types set with the right values. But if I put in a Where filter, it throws an ArgumentOutOfRangeException (TableContext.cs line 335)
using(var db = new MyDb()){
var result = db.GetTable<Person>().Where(p => p.Type == 4).ToList();
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
How to create dynamic entity framework filter expression ...
1 Answer 1 ... Yes, you can. One approach I've used uses an object which is the same as your return type as...
Read more >DataGrid dynamic column filter - Radzen.Blazor Components
I try to initial the data in the OnInitializedAsync function and remove the LoadData function, and it throws the following error when I...
Read more >Help! How to use Filter Query dynamically??
I am new to Power Automate and have a question about how to use Filter Query dynamically. For example, the below shows I...
Read more >Filter records based on dynamic column values - Help
i want to filter to filter the records based on column “department” which is dynamic,where the values under that column may increase. image....
Read more >DataColumn.Expression Property (System.Data)
Gets or sets the expression used to filter rows, calculate the values in a column, or create an aggregate column.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sql.Expr<int>("BIN_AND(OPTIONS, 1)")
Thanks!