.net - Storing NULL instead of blank string columns -
while saving collection changes, how can ensure blank strings should go nulls? using linq, wpf, wcf.
i don't want iterate each record , each property of record put null if blank.
you implement [onserializing] event in wcf datacontract check string.empty , change null. eg:
[datacontract] class mydatastructure { [datamember] string foo { get; set; } [onserializing] void onserializing(streamingcontext context) { if (foo == string.empty) foo = null; } }
and if have lot of string properties , don't want write code test each, use reflection loop through class's properties.
Comments
Post a Comment