none
Business logic RRS feed

  • Question

  • I have the following partial class.
    I want to check if my end date (value) is not before my start date (Begindatum)
    When the following code executes the 'value' contains the right data but most of the other attributes don't have the right data.
    Can I access my attributes here or do I have to do it somewhere else?
    Hope my question is clear.
     public partial class Event
        {
            partial void OnEinddatumChanging(DateTime value)
            {
                if (value.Date < Begindatum)
                {
                    throw new Exception("Not a valid date");
                }
            }
        }

    Sunday, April 11, 2010 7:47 AM

Answers

  • There is a partial OnValidate method you can implement. This way you can make sure that all attributes are set. This method is called when you call SubmitChanges.

    The OnPropertyChanging methods are good when the validation doesn't depend on other attributes.

    • Marked as answer by Kevinvde Sunday, April 11, 2010 9:02 AM
    Sunday, April 11, 2010 8:44 AM

All replies

  • There is a partial OnValidate method you can implement. This way you can make sure that all attributes are set. This method is called when you call SubmitChanges.

    The OnPropertyChanging methods are good when the validation doesn't depend on other attributes.

    • Marked as answer by Kevinvde Sunday, April 11, 2010 9:02 AM
    Sunday, April 11, 2010 8:44 AM
  • Just what I needed,

    thanks a lot 

    Sunday, April 11, 2010 9:02 AM