I need to filter a generic List with data from a Json object. I have the deserialized object in a list with {name:'', value:''}
. I need to search a data contract (which is also a list) with name as the field to search, and value as the value of the field. How do I accomplish these as they are generic.
Here is the method:
public List<StaffingPositionsDataContract> GetStaffingPosition(string searchFilters)
{
List<serializedForm> deserializedObject = JsonConvert.DeserializeObject<List<serializedForm>>(searchFilters);
List<StaffingPositionsDataContract> staffingPositionResponse = new StaffingPositionsDataContract().LoadMockData();
deserializedObject.ForEach(delegate(serializedForm filter) {
});
return staffingPositionResponse;
}
I wanted to try something simple as this:
var query = staffingPositionResponse .Where(filter.name + ".Contains(@0)", filter.value);
But Where does not except 2 arguments. Thanks in advance!