linqllblgen

Is there anyway to use field name with concatenated from the url?


I am trying to search at the same time with pagination so I pass fieldname and fieldvalue to the url and get this. In the example below, I get the fieldname as 'firstName' and fieldValue as 'Jay'. Then I want to search like this but I get this error, ORM blah blah blah.. I am using LLBLgen as ORM but it seems it's more related to linq. Any ideas?

var sm ={
    FieldName:'firstName',
    FieldValue:'Jay'
}

orderModels = orderModels.Where(x => x + "." + sm.FieldName == sm.FieldValue);


Solution

  • You can use System.Dynamic.Linq package so that you can build query dynamically:

    orderModels = orderModels.Where("@0 == @1",sm.FieldName, sm.FieldValue);
    

    See: https://dotnetfiddle.net/cs6MRX