Skip to content

Instantly share code, notes, and snippets.

@edwinf
Created May 29, 2012 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwinf/2822008 to your computer and use it in GitHub Desktop.
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
<#=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