public static TableSelectQuery <TElement> GroupBy <TElement>(this TableSelectQuery <TElement> query, string condition) where TElement : class, new() { query.Filters.Add(new ConditionFilter(FilterType.GroupBy) { Condition = condition }); return(query); }
public static TableSelectQuery <TElement> OrderBy <TElement>(this TableSelectQuery <TElement> query, string condition, Order order) where TElement : class, new() { query.Filters.Add(new OrderFilter(FilterType.OrderBy) { Condition = condition, Order = order }); return(query); }
public virtual string BuildRetrieveQuery <TElement>(TableSelectQuery <TElement> query) where TElement : new() { StringBuilder sb = new StringBuilder(); sb.Append("select "); if (query.Columns.Count == 0) { sb.Append("*"); } else { sb.Append(string.Join(",", query.Columns.Select(column => $"`{column}`"))); } sb.AppendFormat($" from `{TableName}`"); if (!string.IsNullOrEmpty(query.WhereFilter)) { sb.Append($" where {query.WhereFilter}"); } if (query.HasLimit) { sb.AppendFormat($" limit {query.Max}"); } return(sb.ToString()); }
public static TableSelectQuery <TElement> Any <TElement, TOther>(this TableSelectQuery <TElement> query, string column, TableQueryBase otherQuery) where TElement : class, new() where TOther : class, new() { query.Filters.Add(new QueryFilter <TOther>(column, otherQuery, FilterType.Any)); return(query); }
public static TableSelectQuery <TElement> In <TElement, TOther>(this TableSelectQuery <TElement> query, string column, params TOther[] others) where TElement : class, new() { query.Filters.Add(new InItemsFilter <TOther>(others, column)); return(query); }
public static TableSelectQuery <TElement> Between <TElement, TValue>(this TableSelectQuery <TElement> query, string column, TValue value1, TValue value2) where TElement : class, new() { query.Filters.Add(new BetweenFilter <TValue>(column, value1, value2)); return(query); }
public static TableSelectQuery <TElement> Select <TElement>(this TableSelectQuery <TElement> query, string column) where TElement : class, new() { query.Columns.Add(column); return(query); }