Whilst fixing a bug today I came across a nuance of LINQ.
One of our internal notification emails was failing to send emails to the relevent box.
Checking the error logs led me to discover it was failing on the CCAddress field.
Now, this field is optional in the procedure but, from the looks of it rather than it being null it was being set to "" (empty string).
A while back I had added a method to our Email.cs business object. Simple enough a method to SendEmail using an existing stored procedure which adds all the data to the relevent queue table. I could simply have used LINQ to add another queue item but, to maintain consistency I chose to simply call the procedure's data access object.
Apparantly when you create your data access layer the objects created dont take into account the fact that parameters can be optional.
Eventually thanks to the solution I found here :
I found the solution here:
http://www.hookedonlinq.com/CallingStoredProcedureUsingOptionalParameter.ashx
Basically you have to create an overload for the SP LINQ call. No problem and easily done but, shouldnt this be create with the data objects automatically?
It's somewhat annoying, I mean this is hardly an unusual circumstance is it?
No comments:
Post a Comment