I have a EntityDataModel generated from my database (Visual Studio 2010, asp.net 4.0, c#). I am trying to use a partial class associated to an entity class to perform some business logic (in this case check a phone number field and remove spaces).
If I use something like that:
partial void OnMobilePhoneNoChanged()
{
if (MobilePhoneNo != null)
{
MobilePhoneNo = ATG_COModel_Common.FormatPhoneNumber(MobilePhoneNo);
}
}
then I end up getting an infinite loop (because my FormatPhoneNumber method modifies MobilePHoneNo which raises the event again etc) and then I get... a stack overflow!
When I try using the OnMobilePhoneNoChanging instead, and modify the MobilePHoneNo property (or the value
value) then the value is not saved properly.
What should I do ?