"Forgotten" value?
Old forum URL: forums.lhotka.net/forums/t/7587.aspx
ajj3085 posted on Tuesday, September 08, 2009
Hi,
I'm hitting a really wierd problem. The issue is that I have a collection of EmailAddresses on a main Contact object. There are business rules setup to check that the email address is not empty using the standard StringRequired from Csla. This rule has a priorty of 1. A rule with priority 0 performs a Trim of the address, and a rule with priority 2 checks that itx in x@y.com format.
All these checks seem to pass, and the save makes its way to the app server where it's processed. I then get an error because the column for the email address doesn't accept nulls.
The update is simple, and I didn't forget to actually pass the value to the Linq2Sql instance, because the update works most of the time. heres the code:
private void Child_Update( Data.Shared.Person person ) {
ContextManager mgr;
Data.Contacts.SalesContactEmail sce, dummy;
using ( mgr = ContextManager.GetManager() ) {
sce = new Data.Contacts.SalesContactEmail();
sce.SalesContactEmailId = salesContactEmailId;
sce.SalesContact = person.SalesContact;
dummy = new Data.Contacts.SalesContactEmail();
dummy.SalesContactEmailId = salesContactEmailId;
dummy.SalesContact = person.SalesContact;
sce.SalesContact = person.SalesContact;
using ( BypassPropertyChecks ) {
sce.IsPrimary = IsPrimary;
sce.EmailAddress = Email;
}
mgr.DataContext.SalesContactEmail.Attach( sce, dummy );
}
}
Any ideas?rfcdejong replied on Saturday, September 12, 2009
1. Is the property in the businessobject a string? If not then the StringRequired rule won't work.
PS:
What do u mean with a rule performing a Trim? I suppose it's checking if the string is not empty after trimming?
Else i don't have another idea, it should be something simple hehe.rfcdejong replied on Saturday, September 12, 2009
Or maybe a strange value as e-mail address that causes the update to fail. With L2S it shouldn't be a problem, but for example using raw sql it would hick up on comma's.
Is it going wrong in production code? Any logs?ajj3085 replied on Monday, September 14, 2009
I finally found the issue. I had forgotten some attributes on the stored procedure method signature.
What was throwing me is that the update sometimes WOULD work... how I can't figure out, but it would only happen if the user change some of child records, nothing that had to do with the emails collection itself.Copyright (c) Marimer LLC