Tiago Salgado Posted July 23, 2012 at 05:49 PM Report Share #469786 Posted July 23, 2012 at 05:49 PM Boas, Tenho o seguinte modelo: public class Recipe { [Key] 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 { [Key] public int ID { get; set; } [Required] public virtual Recipe Recipe { get; set; } [Required] public string Ingredient { get; set; } [Required] public string Quantity { get; set; } public string Obs { get; set; } [NotMapped] 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. Obrigado Link to comment Share on other sites More sharing options...
Tiago Salgado Posted July 23, 2012 at 06:09 PM Author Report Share #469792 Posted July 23, 2012 at 06:09 PM Epah, fazer as coisas à pressa dá nisto. Desculpem mas o problema está resolvido. Não sei porque raio fui por um [Required] public virtual Recipe Recipe { get; set; } no RecipeIngredients, mas pronto. Caso pretendam, podem remover a thread. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now