Applying Distinct to OData query
Ich möchte eine Liste mit unterschiedlichen Werten von meinem OData-Endpunkt erhalten. Aber distinct oder group by wird noch nicht unterstützt.
Meine URI-Abfrage sieht ungefähr so aus
GET /odata/Products?$select=foo & $top=10 & $count=true & distinct=true
Meine Steuerung
[EnableQuery]
public IQueryable<FooBarBaz> Get(ODataQueryOptions<FooBarBaz> queryOptions, bool distinct)
{
//I've tried the following
return Repository.AsQueryable().Distinct();
// and
return Repository.AsQueryable().GroupBy(x => x.Foo);
// and
IQueryable query = queryOptions.ApplyTo(Repository.AsQueryable());
return query.Distinct(); // Can't call .Distinct() here
}
Keine Arbeit: