Created
May 29, 2012 01:10
-
-
Save edwinf/2822008 to your computer and use it in GitHub Desktop.
How to modify the EF complex object template to not update unless the value is different
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#=code.SpaceAfter(Accessibility.ForSetter(complexProperty))#>set | |
{ | |
if ( (<#=code.FieldName(complexProperty)#> != null && value == null) || | |
(<#=code.FieldName(complexProperty)#> == null && value != null) || | |
(<#=code.FieldName(complexProperty)#> != null && !<#=code.FieldName(complexProperty)#>.Equals(value)) | |
) | |
{ | |
<#=ChangingMethodName(complexProperty)#>(value); | |
ReportPropertyChanging("<#=complexProperty.Name#>"); | |
<#=code.FieldName(complexProperty)#> = SetValidValue(<#=code.FieldName(complexProperty)#>, value, "<#=complexProperty.Name#>"); | |
<#=InitializedTrackingField(complexProperty, code)#> = true; | |
ReportPropertyChanged("<#=complexProperty.Name#>"); | |
<#=ChangedMethodName(complexProperty)#>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment