/// <summary> /// Copy rows from the same table. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="select"></param> /// <returns></returns> public static GXInsertArgs Insert <T>(GXSelectArgs select) { GXInsertArgs args = new GXInsertArgs(); select.Parent.Settings = args.Parent.Settings; args.Parent.Updated = true; Expression <Func <T, object> > expression = _ => typeof(T); args.Values.Add(new KeyValuePair <object, LambdaExpression>(select, expression)); return(args); }
private static GXSelectArgs SelectByIdInternal <T, IDTYPE>(IDTYPE id, Expression <Func <T, object> > columns) { GXSelectArgs arg = GXSelectArgs.Select <T>(columns); GXSerializedItem si = GXSqlBuilder.FindUnique(typeof(T)); if (si == null) { throw new ArgumentException("Select by ID failed. Target class must be derived from IUnique."); } string name = GXDbHelpers.GetColumnName(si.Target as PropertyInfo, '\0'); arg.Where.Or <IUnique <T> >(q => name.Equals(id)); return(arg); }
public static GXSelectArgs Select <T>(Expression <Func <T, object> > columns) { GXSelectArgs arg = new GXSelectArgs(); if (columns != null) { arg.Columns.Add <T>(columns); } else { arg.Columns.Add <T>(q => "*"); } return(arg); }
internal static void OrderByToString(GXSelectArgs parent, StringBuilder sb, List <GXOrder> OrderList, List <GXJoin> joinList) { bool first = true; if (OrderList.Count != 0) { sb.Append(" ORDER BY "); first = true; foreach (GXOrder it in OrderList) { if (first) { first = false; } else { sb.Append(", "); } if (parent.Settings.Type == DatabaseType.MSSQL && parent.Count != 0) { string table = GXDbHelpers.GetTableName(it.Table, true, '\0', parent.Settings.TablePrefix); sb.Append(GXDbHelpers.AddQuotes(table + '.' + it.Column, parent.Settings.ColumnQuotation)); continue; } //Add table name always until there is a way to check are multiple tables used. if (joinList.Count != 0) { string table = GXDbHelpers.GetTableName(it.Table, true, parent.Settings.TableQuotation, parent.Settings.TablePrefix); sb.Append(table); sb.Append('.'); } sb.Append(GXDbHelpers.AddQuotes(it.Column, parent.Settings.ColumnQuotation)); } if (parent.Descending) { sb.Append(" DESC"); } } }
internal static void GroupByToString(GXSelectArgs parent, StringBuilder sb, List <GXOrder> groupList, List <GXJoin> joinList) { if (groupList.Count != 0) { sb.Append(" GROUP BY "); bool first = true; foreach (GXOrder it in groupList) { if (first) { first = false; } else { sb.Append(", "); } //Table name is not added if there is only one table. if (joinList.Count != 0) { if (parent.Settings.Type == DatabaseType.MSSQL && parent.Count != 0) { string table = GXDbHelpers.GetTableName(it.Table, true, '\0', parent.Settings.TablePrefix); sb.Append(table); sb.Append('.'); } else { string table = GXDbHelpers.GetTableName(it.Table, true, parent.Settings.TableQuotation, parent.Settings.TablePrefix); sb.Append(table); sb.Append('.'); } } sb.Append(GXDbHelpers.AddQuotes(it.Column, parent.Settings.ColumnQuotation)); } } }
/// <summary> /// Is value exists in the table. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="expression">Value to search.</param> /// <returns>True, if value exists.</returns> public static bool Exists <TSourceTable, TDestinationTable>(Expression <Func <TSourceTable, object> > sourceColumn, Expression <Func <TDestinationTable, object> > destinationColumn, GXSelectArgs expression) { return(true); }
public static bool In(object value, GXSelectArgs expression) { return(true); }
/// <summary> /// Is value exists in the table. /// </summary> /// <param name="args">Selection arguments.</param> /// <returns>True, if value exists.</returns> public static bool Exists(GXSelectArgs args) { return(true); }
/// <summary> /// Constructor. /// </summary> internal GXOrderByCollection(GXSelectArgs parent) { Parent = parent; }
/// <summary> /// Constructor. /// </summary> internal GXGroupByCollection(GXSelectArgs parent) { Parent = parent; }
public void Add <T>(GXSelectArgs select, Expression <Func <T, object> > columns) { Parent.Updated = true; Values.Add(new KeyValuePair <object, LambdaExpression>(select, columns)); }