Jump to content

[Resolvido] Adicionar exclusão no Bind

Tiago Salgado

Recommended Posts


Tenho o seguinte modelo:

public class Recipe
    public int ID { get; set; }
    public DateTime Created { get; set; }
    public DateTime Updated { get; set; }
    public string Name { get; set; }
    public virtual List<RecipeIngredients> RecipeIngredients { get; set; }
public class RecipeIngredients
    public int ID { get; set; }
    public virtual Recipe Recipe { get; set; }
    public string Ingredient { get; set; }
    public string Quantity { get; set; }
    public string Obs { get; set; }
    public Guid? identifier { get; set; }

Na criação de um Recipe, o ModelState passa sempre como inválido, pois diz que não valida o campo Recipe na classe RecipeIngredients.

Como consigo indicar que não quero que ele me valide esse campo (virtual), da mesma forma que o ID por exemplo?

Tenho definido o Bind(Exclude="Id"), mas não consigo atinar com a exclusão do do Recipe.


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.