I have following class hierarchy:
public class Company
{
public ICollection<CompanyType> CompanyTypes { get; set; } = new List<CompanyType>();
}
public class CompanyType
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public static implicit operator int(CompanyType companyType) => companyType.Id;
}
Now I would like to get an Filter from Odata query and convert it to Expression.
I am getting following error:
Could not find a property named 'Id' on type 'Edm.Int32'.
This is my query:
$filter=CompanyTypes/any(s: s/Id eq 1)&$skip=0&$top=2
I tried to use that code:
//ODataQueryOptions<GetCompaniesRequestV2> request
...
IQueryable queryable = Enumerable.Empty<Company>().AsQueryable();
queryable = request.Filter.ApplyTo(queryable, new ODataQuerySettings());
New contributor
w.johnny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1