简体   繁体   中英

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);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM