schotime / NPoco

Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco
Apache License 2.0
848 stars 302 forks source link

Using extension methods in query? #705

Open PeterN opened 1 month ago

PeterN commented 1 month ago

Given the following dummy code...

public class Test {
   public int Value { get; set; }
}

public static class TestExtensions {
   public bool BiggerThanPi(this Test test) => test.Value >= 4;
}

Is it possible to make database.Query<Test>().Where(x => x.BiggerThanPi()).ToList() work?

Reason for this is 1) to avoid repeating the test in lots of place, 2) the code compiles no problem but is a runtime error in the expression visitor.