I'm trying to pass a bind array instead of defining in the parameters. For example, this code:
[HttpPost]
[Route("Create")]
public ResultsItem Create([Bind(nameof(Person.Username), nameof(Person.Password))] Person)
{
...
}
It works fine, however, if it gets big, I'll have a big bind list. I wanted to define it in the class instead like below:
Person.cs
public static readonly string[] BindInclude = new[] { nameof(Username), nameof(Password) };
public ResultsItem Create([Bind(Person.BindInclude)] Person newUser)
However, I am getting the following error:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.
I understand the error, however I'm wondering does anyone have a good way for doing this? Let's say I have a big class, however, I only want to bind like 6 - 10 properties. How can I do this without flooding the Bind[()]
in controller.