public static string GetInSqlServerPageListSelectSql(this ISelectProperties selectProperties, int id = 0, string tableIndex = null, List <List <object> > listsIn = null, string sqlAppend = "", params string[] properties) { string result = string.Empty; StringBuilder builder = new StringBuilder(); var selectColumnNames = GetSelectColumnSql(selectProperties, id, properties); var headersAndFooters = selectProperties.GetStatisticHeaderAndFooterSql(id); string header = string.Empty; string footer = string.Empty; if (headersAndFooters.ContainsKey(StatisticsType.Header)) { header = headersAndFooters[StatisticsType.Header]; } if (headersAndFooters.ContainsKey(StatisticsType.Footer)) { footer = headersAndFooters[StatisticsType.Footer]; } var tableName = selectProperties.GetTableName(tableIndex); var collectionLimit = selectProperties.GetSelectCollectionLimit(id); var row_number = string.Format(PageListSql.PageListSqlServer1_0, string.IsNullOrEmpty(footer) ? " order by getdate() " : footer); var row_numberColumn = string.Format(PageListSql.PageListSqlServer1, row_number); builder.AppendLine(string.Format("Select {3} {0} {1} From {2} ", collectionLimit, selectColumnNames.ToString(), tableName, row_numberColumn)); var matchedKeys = selectProperties.GetInMatchedKeyNameAndValues(id, true, listsIn?.ToArray()); builder.AppendJoin(" ", matchedKeys); builder.AppendLine(sqlAppend); builder.Append(footer); result = builder.ToString(); //result = string.Format(PageListSql.PageListSqlServer, PageListSql.PageListSqlServerTopSize0, innerSql); return(result); }
public static string GetSelectSql(this ISelectProperties selectProperties, int id = 0, string tableIndex = null, string sqlAppend = "", params string[] properties) { string result = string.Empty; StringBuilder builder = new StringBuilder(); var selectColumnNames = GetSelectColumnSql(selectProperties, id, properties); var tableName = selectProperties.GetTableName(tableIndex); var collectionLimit = selectProperties.GetSelectCollectionLimit(id); builder.AppendLine(string.Format("Select {0} {1} From {2} ", collectionLimit, selectColumnNames.ToString(), tableName)); var matchedKeys = selectProperties.GetMatchedKeyNameAndValues(id); builder.AppendJoin(" ", matchedKeys); builder.AppendLine(sqlAppend); result = builder.ToString(); return(result); }