I am having a real problem with handling nulls...

Nov 29, 2012 at 10:53 PM
Edited Nov 29, 2012 at 10:55 PM

Hi All,

I am new here, and to Value Injector which looks excellent. However I think I am suffering from user ignorance. I am trying to ignore nulls in a MVC Model("Source") which seem to be overwritting my Document model properties("Target").

I have the full question on StackOverflow at:

StackOverflow Question

I would hugely appreciate any help.

Many thanks,

Ed

Coordinator
Nov 29, 2012 at 11:07 PM

answered to so question

Nov 29, 2012 at 11:32 PM
Edited Nov 29, 2012 at 11:35 PM

Chuck,

Thanks for this, but it does not seem to work. You will see from my debugger screens that I am dealing with properties that contain classes ie "Client". I was wondering whether the issue was to do with the fact that the form had a subset of the Class Properties, but the Model Binder would just set these properties to null anyway, and the ValueInjector would process the object and not the forms collection.

I really appreciate your help. Thanks.

Ed

P.S This is also on SO.

Nov 30, 2012 at 12:49 AM

Hi,

I believe the issue is to do with nested subclasses since the toplevel is never null which ValueInjecter seems to be checking. It has a value of {XSD_Smart2.DocumentIntroduction} for example as detailed by the debugger. Perhaps this is why

&& c.SourceProp.Value != null;

will not work, and I need something a little more involved to check the nesting.

Thanks,

Ed

Nov 30, 2012 at 1:00 AM

Hi,

I think  I need something like the "Deep Cloning" approach, but does this take care of nested classes? Obviously there are the standard types like arrays, lists etc.

I think I am getting warmer.....

Ed