public static System.String TrimToNull( this System.String @string ) {
if ( System.String.IsNullOrEmpty( @string ) ) {
return null;
}
@string = @string.Trim();
return ( System.String.IsNullOrEmpty( @string ) )
? null
: @string
;
}
public static System.String CommaListToSingleQuotedCommaList( System.String commaList ) {
commaList = commaList.TrimToNull();
return ( null == commaList )
? null
: System.String.Join(
",",
commaList.Split( new System.Char[ 1 ] { ',' },
System.StringSplitOptions.RemoveEmptyEntries
).Select(
x => !x.Contains( "'" )
? x
: x.Contains( "''" )
? x
: x.Replace( "'", "''" )
).Select(
x => "'" + x.TrimToNull() + "'"
) )
;
}
Comments