Suppose I have a form that has the following:
Name: TextBox
Email: TextBox
Age: TextBox
now i want to get customer collection based on these filter text fields
so I want to use something like:
List<customer> customers = getCustomerswhere(c=>c.name == txtName.Text && Email == txtEmail.Text);
now, of course, I don’t know what it will fill and that it will not be so
if (txtName.Text.trim() != "") //something like c=>c.Name == txtName.text; if (txtEmail.Text.trim() != "") //something like and c=>c.Email == txtEmail.text;
how i do it! I cannot concatenate lambda expressions, I know I can use dynamic expressions, but I think there is an easier way? any idea how to implement this?
ok I tried this:
Func<Customer,bool > a = (bb) => bb.fullName == "asdfsd"; Func<Customer, bool> b = c => c.lastName == "sdas"; Func<Customer, bool> cc = c => a(c) && b(c);
now another problem arises
im method going through CC to expects Expression<Func<T, bool>> expression
so it doesn’t work, gives me a compilation of time error can not convert between types!
source share