Search code examples
c#asp.net-web-apiodata

webapi filter properties from dictionary<string,string>


I return a IQueriable<Dictionary<string,string>> in my POST method. I want to be able to apply OData filter on the dictionary. For example:

dictionary is

Key = Place
Value = New York

my filter is ?$filter=Place eq 'New York'

**

But I get an error: ":"Instance property 'Place' is not defined for type 'System.Collections.Generic.Dictionary`2[System.String

**


Solution

  • Found a solution with third party lib. LinqToQuerystring

    var queryValue = Request.RequestUri.ParseQueryString(); return _dictionary.LinqToQuerystring(queryValue.ToString());