-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Querying with explicit property specification (without attributes) #4
Comments
For 2, this is already supported using
I completely agree with 1 & 3 so I'll get started working on this. Will also have a look at your PR in a sec. Glad you liked Sieve! |
Had a look at your PR, thanks a lot for taking the time to write that! Seems like a reasonable way of doing it, but I don't like that it uses arguments to pass the array of Instead, I propose having a centralized location where these mappings could be defined. One way would be to allow overriding a method of Here's how to use it: public class ApplicationSieveProcessor : SieveProcessor
{
public ApplicationSieveProcessor(
IOptions<SieveOptions> options,
ISieveCustomSortMethods customSortMethods,
ISieveCustomFilterMethods customFilterMethods)
: base(options, customSortMethods, customFilterMethods)
{
}
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
{
mapper.Property<Post>(p => p.Title)
.CanFilter()
.HasName("a_different_query_name_here");
mapper.Property<Post>(p => p.CommentCount)
.CanSort();
mapper.Property<Post>(p => p.DateCreated)
.CanSort()
.CanFilter()
.HasName("created_on");
return mapper;
}
} Now you should inject the new class instead: services.AddScoped<ISieveProcessor, ApplicationSieveProcessor>(); This should be familiar to developers since a similar pattern is used to extend |
Thank you, works for me! |
I'm sorry but after I added this code to my startup.cs : Then I found an error message like this :
Can anyone help me? Thank you |
Probably, you don't use custom sort/filter methods. Try to activate
|
Hello I used this code but it doesn't work for nested class I add |
I would like to be able to (optionally) explicitly specify which properties are used for the queries instead of using the Sieve attribute. Ideally, this "specification" would also allow the definition of a mapping between a query term to an actual property on the model class.
My arguments supporting this request:
Here is an example of how the changed call to SieveProcessor could look like:
` var result = _dbContext.Posts.AsNoTracking();
I have implemented a draft of the necessary changes and will open a PR. Feedback is welcome!
BTW: Great work so far!
The text was updated successfully, but these errors were encountered: