bbartels / delve Goto Github PK
View Code? Open in Web Editor NEWLightweight ASP.NET Core MVC Pagination, Filtering, Sorting, Expanding and DataShaping Library
License: MIT License
Lightweight ASP.NET Core MVC Pagination, Filtering, Sorting, Expanding and DataShaping Library
License: MIT License
Hi Benjamin,
when I send request e.g. http://localhost:51607/api/user?filter=FirstName!=Veronica
, I noticed that library is generating X-Pagination nextPageLink as http://localhost:51607/api/User?pageNumber=2&pageSize=5&filter=FirstName!%3Dveronica
with %3D
instead of =
character.
It would be nice when characters would not be URL encoded (Percent Encoded).
Thanks,
Branislav
Hi Benjamin,
thanks for awesome and useful library. It is exactly that I was looking for to implement in my REST APIs.
Do you have plan to implement CaseInsensitive NotEqual !=*
operator?
Thanks,
Branislav
I use SQL 2017 to store json documents and need to pass filters from API to apply on json properties. I also need projection to return only necessary properties and pagination. Does this library support querying on json documents or is there any modifications needed to make it work?
Hi Benjamin,
when I have class User without UserQueryValidator part like:
public class User
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
public IEnumerable<UserRole> UserRoles { get; set; }
public User() { }
public User(string firstName, string lastName, DateTime dateOfBirth)
{
FirstName = firstName;
LastName = lastName;
DateOfBirth = dateOfBirth;
}
}
and call http://localhost:{port}/api/user i get exception RuntimeException: No service registered for QueryValidator: Delve.Models.Validation.IQueryValidator`1[Delve.Demo.Models.User], but I don't want to have any query validation on User class in this case.
Hi Benjamin,
I figured out that ShapeData
method "shapes" data after being retrieved from database with all columns (including columns data that we don't want). Do you plan to improve deffered query build with inlcuding select criteria before sending query to database.
Thanks,
Branislav
Hi Benjamin,
what you think about adding method in AbstractQueryValidator
to set certain property as default sort property if we don't want to sort results by primary key 'Id' by default:
public class UserQueryValidator : AbstractQueryValidator<User>
{
public UserQueryValidator()
{
SetDefaultSortProperty("FirstName", x => x.FirstName, descending: true, order: 1);
SetDefaultSortProperty("LastName", x => x.LastName, descending: false, order: 2);
}
}
or to go with custom property attribute:
public class User
{
public int Id { get; set; }
[DefaultSortProperty(descending = true, order = 1)]
public string FirstName { get; set; }
[DefaultSortProperty(descending = false, order = 2)]
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
}
If we have two or more default order properties it will pick up first by lowest order number and sort result by that property.
Hi Benjamin,
I want to report if AddDefaultSort
method is not called in {SomeEntityName}QueryValidator class (default sorting is not set for this particular entity class) then exception of type ArgumentOutOfRangeException
is thrown. E.g., for this code:
public class UserQueryValidator : AbstractQueryValidator<User>
{
public UserQueryValidator()
{
//Adds virtual property as default sort
//AddDefaultSort(u => u.LastName + " " + u.LastName, true);
}
}
exception is thrown in QueryConfiguration.cs
file:
public IQueryable<T> ApplyDefaultSorts(IQueryable<T> source)
{
if (source == null) { return null; }
// on this line exception is thrown
var orderedSort = _defaultSorts[0].ApplySort(source);
for (int i = 1; i < _defaultSorts.Count; i++)
{
orderedSort = _defaultSorts[i].ApplySort(orderedSort);
}
}
Hi Benjamin,
when we send request like:
GET /api/Users
?filter= Age>=20, Name$*Smith|Bullock
&orderby= -Age, Name
&select= Id, Name, Age
&expand= UserRoles
&pageNumber= 1
&pageSize= 10
we expose our internal domain class name (navigation property) UserRoles
to end users and I think it violates some of the REST API recommendation which suggests that we should hide our domain classes.
Accordingly, it would be good in CanExpand
method that we could set string key
like in other methods (CanSelect, CanFilter, CanOrder) which maps to our internal domain class like CanExpand("RolesOfUser", x => x.UserRoles)
to hide our internal class name.
Thanks,
Branislav
Hi Benjamin,
have you thought about adding AddDefaultExpand
method to QueryValidator
where navigation property will be loaded by default because now is null
. E.g. for class User
:
public class User
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
public IEnumerable<UserRole> UserRoles { get; set; }
}
UserRoles
property is null
, but with setting AddDefaultExpand(x => x.UserRoles)
or AddDefaultExpand(x => x.UserRoles.Select(ur => ur.Role))
, UserRoles
property or UserRoles
with Roles
will be populated.
Hi Benjamin,
when I set OmitHostOnPaginationLinks = true
in Delve configuration, method OmitHost
in ResourceUriHelper
throws exception NullReferenceException: Object reference not set to an instance of an object.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.