Extended SieveProcessor to optionally accept a list of SieveProperties.

This commit is contained in:
Thomas Flanitzer
2018-02-09 09:12:34 +01:00
parent aa6a836cfb
commit c9014a913c
5 changed files with 99 additions and 13 deletions

View File

@@ -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)
{