none
Validate data input into the navigation properties RRS feed

  • Question

  • I would like to know how to validate data in navigation properties.

    Example:Product.Ingredients.Add(new Ingredient())

    How can I verify if all ingredients is there at database before using SaveChanges()?

    Even if I use a repository, a developer can set a new Ingredient using Product.Ingredient, so repository is not my anwser.

    Can someone help me?


    http://www.linkedin.com/pub/murilo-kunze/44/191/455


    Monday, May 28, 2012 2:22 PM

All replies

  • You could expose a SaveChanges() method in your repository that hides the context.SaveChanges() method and can do additional checks before calling context.SaveChanges().
    Monday, May 28, 2012 11:43 PM
  • But I use UnitOfWork to save my changes, not directly from repository.

    http://www.linkedin.com/pub/murilo-kunze/44/191/455

    Tuesday, May 29, 2012 11:52 AM