public void Get_does_not_includes_nav_properties_when_not_specified() { var david = new Person { Name = "David", Foo = new Foo { Bar = "a" }, Car = new Car { Model = "Honda" } }; var tom = new Person { Name = "Tom", Foo = new Foo { Bar = "b" } }; var sut = GetSut(); sut.Add(david, tom); var queryString = $"?name={david.Name}"; var parsedQuery = QueryHelpers.ParseQuery(queryString); var request = new QueryablePersonRequest(); request.SetQueryParams(parsedQuery); var results = sut.Get(request).First(); Assert.Null(results.Car); }
public void Get_applies_filters_to_query() { var david = new Person { Name = "David", Foo = new Foo { Bar = "a" } }; var tom = new Person { Name = "Tom", Foo = new Foo { Bar = "b" } }; var sut = GetSut(); sut.Add(david, tom); var queryString = $"?name={tom.Name}&bar={tom.Foo.Bar}"; var parsedQuery = QueryHelpers.ParseQuery(queryString); var request = new QueryablePersonRequest(); request.SetQueryParams(parsedQuery); var results = sut.Get(request); Assert.Contains(results, p => p.Name == tom.Name); Assert.DoesNotContain(results, p => p.Name == david.Name); }
public IEnumerable <Person> Get(QueryablePersonRequest request) { var query = new QueryBuilder <Person>(_db.Person) .Include(request.Includes) .Filter(request.Filters) .Sort(request.SortCriteria) .Build(); return(query.ToList()); }
public IActionResult Get(QueryablePersonRequest req) { return(Ok(req)); }