private static string GetColumnListItem(InterpolationArgs args) { if (string.Compare(args.TemplateName, "SELECT", true) == 0) { return string.Format( "{1}{2}{3}{0}", args.ColumnIndex == args.Columns.Count - 1 ? string.Empty : Environment.NewLine, args.ColumnIndex == 0 ? string.Empty : args.IndentString, args.ColumnIndex == 0 ? " " : ",", GetColumnWithTableAlias(args) ); } else if (string.Compare(args.TemplateName, "INSERT", true) == 0) { string column = GetColumn(args); string item = string.Format( "{1}{2}[{3}]{0}", args.IsLastNonIdentity(column) ? string.Empty : Environment.NewLine, args.IsFirstNonIdentity(column) ? string.Empty : args.IndentString, args.IsFirstNonIdentity(column) ? " " : ",", column ); return args.IsIdentity(column) ? string.Empty : item; } else if (string.Compare(args.TemplateName, "UPDATE", true) == 0) { string column = GetColumn(args); string item = string.Format( "{1}{2}[{3}] = {4}{0}", args.IsLastNonIdentity(column) ? string.Empty : Environment.NewLine, args.IsFirstNonIdentity(column) ? string.Empty : args.IndentString, args.IsFirstNonIdentity(column) ? " " : ",", column, GetParameter(args) ); return args.IsIdentity(column) ? string.Empty : item; } else { return "??ColumnListItem??"; } }
private static void GetParameterListItemPunc(InterpolationArgs args, string column, out string conjunction, out string indent, out string endLine) { if (args.TemplateName == "DELETE") { conjunction = GetConjunction(args, dr => args.IsPrimaryKey(dr["COLUMN_NAME"].ToString()), string.Empty, " ", ","); indent = args.IsFirstPrimaryKey(column) ? string.Empty : args.IndentString; endLine = args.IsLastPrimaryKey(column) ? string.Empty : Environment.NewLine; } else if (args.TemplateName == "INSERT") { conjunction = GetConjunction(args, dr => !args.IsIdentity(dr["COLUMN_NAME"].ToString()), string.Empty, " ", ","); indent = args.IsFirstNonIdentity(column) ? string.Empty : args.IndentString; endLine = args.IsLastNonIdentity(column) ? string.Empty : Environment.NewLine; } else { conjunction = GetConjunction(args, string.Empty, " ", ","); indent = args.ColumnIndex == 0 ? string.Empty : args.IndentString; endLine = args.ColumnIndex == args.Columns.Count - 1 ? string.Empty : Environment.NewLine; } }
private static string GetValueListItem(InterpolationArgs args) { string column = GetColumn(args); if (args.IsIdentity(column)) { return string.Empty; } string conjunction = GetConjunction(args, dr => !args.IsIdentity(dr["COLUMN_NAME"].ToString()), string.Empty, " ", ","); string indent = args.IsFirstNonIdentity(column) ? string.Empty : args.IndentString; string endLine = args.IsLastNonIdentity(column) ? string.Empty : Environment.NewLine; return string.Format( "{1}{2}{3}{0}", /* 0 */ endLine, /* 1 */ indent, /* 2 */ conjunction, /* 3 */ GetParameter(args) ); }
private static string GetParameterListItem(InterpolationArgs args, string column, string item) { if (args.TemplateName == "INSERT") { return args.IsIdentity(column) ? string.Empty : item; } else if (args.TemplateName == "DELETE") { return args.IsPrimaryKey(column) ? item : string.Empty; } else { return item; } }