mirror of
https://github.com/Biarity/Sieve.git
synced 2025-10-18 19:36:50 +02:00
Extended SieveProcessor to optionally accept a list of SieveProperties.
This commit is contained in:
@@ -33,6 +33,24 @@ namespace SieveTests.Controllers
|
||||
return Json(result.ToList());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult GetAllWithSieveAndPropertyMapping(SieveModel sieveModel)
|
||||
{
|
||||
var result = _dbContext.Posts.AsNoTracking();
|
||||
|
||||
var sieveProperties = new[]
|
||||
{
|
||||
SieveProperty<Post>.For(_ => _.Title, Allow.Filter, "name"),
|
||||
SieveProperty<Post>.For(_ => _.CommentCount, Allow.SortAndFilter),
|
||||
SieveProperty<Post>.For(_ => _.LikeCount, Allow.Sort),
|
||||
SieveProperty<Post>.For(_ => _.DateCreated, Allow.SortAndFilter),
|
||||
};
|
||||
|
||||
result = _sieveProcessor.ApplyAll(sieveModel, result, sieveProperties);
|
||||
|
||||
return Json(result.ToList());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult Create(int number = 10)
|
||||
{
|
||||
|
Reference in New Issue
Block a user