Skip to content
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

Feature Request: Filter by property which is passed as a string variable #101

Closed
prochnowc opened this issue Aug 23, 2022 · 4 comments
Closed
Labels
analysis Problem analysis

Comments

@prochnowc
Copy link
Contributor

Hi,

I have a use case where the user can enter the name of the property which should be used to filter the result set.
Currently this is not possible because

string propertyName = "myProperty";
builder.Filter(e => propertyName == "test")

is being rendered as

propertyName eq 'test'

instead of the wanted

myProperty eq 'test'

Do you think you can add such feature ?
Eg. by passing a special static function like so:

Filter(e => ODataProperty.ByName(propertyName) == "value")

Thanks in advance!

@prochnowc prochnowc changed the title Fequte Request: Filter by property which is passed as a string variable Feature Request: Filter by property which is passed as a string variable Aug 23, 2022
@ZEXSM ZEXSM added the analysis Problem analysis label Aug 23, 2022
@ZEXSM
Copy link
Owner

ZEXSM commented Aug 23, 2022

Hi!

Please attach a complete usage example, starting with creating an ODataQueryBuilder instance.

Do I understand correctly that there is a need for a dynamic property name?

@prochnowc
Copy link
Contributor Author

Do I understand correctly that there is a need for a dynamic property name?

yes

A complete example would be:

string propertyName = "ODataKind.ODataCode.IdCode";
new ODataQueryBuilder()
  .For<ODataTypeEntity>()
  .ByList()
  .Filter((s,f,_) => f.Property<int>(propertyName) >= 3)
  .ToUri();

@ZEXSM
Copy link
Owner

ZEXSM commented Aug 27, 2022

Do I understand correctly that there is a need for a dynamic property name?

yes

A complete example would be:

string propertyName = "ODataKind.ODataCode.IdCode";
new ODataQueryBuilder()
  .For<ODataTypeEntity>()
  .ByList()
  .Filter((s,f,_) => f.Property<int>(propertyName) >= 3)
  .ToUri();

Possibly related #99

@prochnowc
Copy link
Contributor Author

prochnowc commented Aug 27, 2022

What do you think about the PR @ZEXSM ? It would be great to have this feature merged.

@ZEXSM ZEXSM closed this as completed Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Problem analysis
Projects
None yet
Development

No branches or pull requests

2 participants