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

Improve TryBindQueryString with understanding MVC's FromQueryAttribute Name property #523

Open
abelbraaksma opened this issue Sep 1, 2022 · 0 comments

Comments

@abelbraaksma
Copy link

abelbraaksma commented Sep 1, 2022

Today we (cc: @nkeenan38) tried to use TryBindQueryString, or the Context.tryBindQuery<_> function to bind to an object that contained PascalCase for what was snake_case in the query string.

type UserQueryInfo =
    { [<FromQuery(Name = "user_id")>]
      UserId: string }

With a querystring ?user_id=2345678, this won't work. Context.tryBindQuery<_> context will complain that it cannot find UserId.

So I looked over the code and noticed that the dictionary of key-value pairs is inspected with case-insensitivity, but other than that it must be an exact match. Yet it would be awesome if we can either allow automatic conversion of snake_case => SnakeCase properties, or that one of the MVC attributes get recognized.

I think FromQueryAttribute is a good candidate and greatly improves the usability of this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant