Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Support [Bind] attribute for compatibility with MVC5 #982

Closed
Praburaj opened this issue Aug 12, 2014 · 5 comments
Closed

Support [Bind] attribute for compatibility with MVC5 #982

Praburaj opened this issue Aug 12, 2014 · 5 comments

Comments

@Praburaj
Copy link
Contributor

In MVC 5 we have the ability to specify [Bind(Include = "comma separated field names")].

Right now [BindRequired] or [BindNever] needs to be set at property level.

@yishaigalatzer
Copy link
Contributor

We should add the Bind attribute, but we should make sure our samples use nameof()

e.g. [Bind(Include = nameof(Prop1) + "," + nameof(Prop2)]

@yishaigalatzer
Copy link
Contributor

@harshgMSFT

@yishaigalatzer yishaigalatzer added this to the 6.0.0-beta1 milestone Aug 27, 2014
@Praburaj Praburaj changed the title Ability to specify [BindNever] or [BindRequired] at a class level Support [Bind] attribute for compatibility with MVC5 Oct 8, 2014
@harshgMSFT
Copy link
Contributor

Adding some more context about the bug:

Bind Attribute

  1. Can be specified at class or parameter level.
  2. It defines three properties :
    a. Include: Can be used to selectively include properties.Is applicable for parameters and types.
    b. Exclude: Can be used to selectively exclude the properties.Is applicable for parameters and types.
    c. Prefix : Only applicable if this attribute is decorating a parameter.

2.a and 2.b can be achieved using the
[BindRequired] and [BindNever] attribute by defining them directly on the properties or on the Type definition.
Gaps:

  1. Bind Required and Bind Never cannot be annotated on Parameters.
  2. There is no way to provide prefix value for the parameters.
  3. [BindRequired] and [BindNever] do validation as well. Historically this was to prevent under binding ( i.e to ensure that the model has a user provided value and not a default value).

@rynowak
Copy link
Member

rynowak commented Oct 17, 2014

Resolved by: 5405e3b761ad8c55f8fbd1ef311454342568860

@harshgMSFT
Copy link
Contributor

75405e3

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

No branches or pull requests

5 participants