/// <summary> /// Returns collection of Exec the PV_WLWEBGetActiveTablesForTableInstruction /// /// </summary> /// <param name="wLLocationID">The wLLocationID.</param> /// <returns>Collection with resultSet</returns> public WLTableCollection CollExecWLWEBGetActiveTablesForTableInstruction(long? wLLocationID) { SqlQuery query = new SqlQuery("PV_WLWEBGetActiveTablesForTableInstruction", mySql); SqlParameter prm_ret_value = query.AddParam("@RETURN_VALUE", SqlDbType.Int, 4, DBNull.Value, ParameterDirection.ReturnValue); query.AddParam("@WLLocationID", SqlDbType.BigInt, 0, 19, wLLocationID, ParameterDirection.Input); WLTableCollection ret_coll = new WLTableCollection(); SqlDataReader dr = query.ExecuteReader(); try { while (dr.Read()) ret_coll.Add(MakeDtoByReader(dr)); } finally { dr.Close(); } int? func_ret = MyConvert.ToIntN(prm_ret_value.Value); if (func_ret != null && func_ret != 0) throw new SpNonZeroReturnException(func_ret.Value, "PV_WLWEBGetActiveTablesForTableInstruction"); return ret_coll; }
/// <summary> /// Does the delete. /// </summary> /// <param name="id">The id.</param> /// <param name="sql">The sql object.</param> private static void DoDelete(long id, MySql sql) { SqlQuery query = new SqlQuery("PA_WLTableMessages_DEL", sql); query.AddParam("@WLTableId", SqlDbType.BigInt, 0, id, ParameterDirection.Input); query.ExecuteStoreProc(); }
public static DataTable GetResponseRawDataTF(long top) { SqlQuery query = new SqlQuery("PV_LRSWEBGetResponseRawData_TF", ConnectionFactory.CreateMySql("SRV")); SqlParameter prm_ret_value = query.AddParam("@RETURN_VALUE", SqlDbType.Int, 4, DBNull.Value, ParameterDirection.ReturnValue); query.AddParam("@Top", SqlDbType.BigInt, 0, 19, top, ParameterDirection.Input); DataTable ret_data_table = query.ExecuteDataTable(); int? func_ret = MyConvert.ToIntN(prm_ret_value.Value); if (func_ret != null && func_ret != 0) { throw new SpNonZeroReturnException(func_ret.Value, "PV_LRSWEBGetResponseRawData_TF"); } return(ret_data_table); }
/// <summary> /// Does the read. /// </summary> /// <param name="id">The id.</param> /// <param name="sql">The SQL.</param> /// <returns>read WLTableMessagesDto</returns> /// <exception cref="NoSingleRowReturnedException">when 0 or more than one row is returned</exception> private static WLTableMessagesDto DoRead(long id, MySql sql) { SqlQuery query = new SqlQuery("PA_WLTableMessages_SEL", sql); query.AddParam("@WLTableId", SqlDbType.BigInt, 0, id, ParameterDirection.Input); WLTableMessagesDto dto; SqlDataReader dr = query.ExecuteReader(); try { int rowsCalc; if (dr.Read()) { dto = MakeDtoByReader(dr); rowsCalc = 1; while (dr.Read()) { rowsCalc++; } } else { throw new NoSingleRowReturnedException(0, "PA_WLTableMessages_SEL", query.ToString()); } if (rowsCalc != 1) { throw new NoSingleRowReturnedException(rowsCalc, "PA_WLTableMessages_SEL", query.ToString()); } } finally { dr.Close(); } return(dto); }
/// <summary> /// Saves the specified dto. /// </summary> /// <param name="dto">The dto.</param> /// <param name="mySql">My SQL.</param> private static void DoSave(WLTableMessagesDto dto, MySql mySql) { bool isNew = dto.IsNew; string queryType = isNew ? "INS" : "UPD"; SqlQuery query = new SqlQuery("PA_WLTableMessages_" + queryType, mySql); query.AddParam("@WLTableId", SqlDbType.BigInt, 0, dto.WLTableId, ParameterDirection.Input); query.AddParam("@BeachButlerMessage", SqlDbType.NVarChar, 200, dto.BeachButlerMessage, ParameterDirection.Input); query.AddParam("@TableGenieLeftButtonMessage", SqlDbType.NVarChar, 200, dto.TableGenieLeftButtonMessage, ParameterDirection.Input); query.AddParam("@TableGenieMiddleButtonMessage", SqlDbType.NVarChar, 200, dto.TableGenieMiddleButtonMessage, ParameterDirection.Input); query.AddParam("@TableGenieRightButtonMessage", SqlDbType.NVarChar, 200, dto.TableGenieRightButtonMessage, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId", SqlDbType.Int, 4, dto.WLDictChangeStatusId, ParameterDirection.Input); query.ExecuteStoreProc(); if (dto.IsNew) { dto.SetIsNew(false); } }
/// <summary> /// Odczyt kolekcji z SEL_ALL (na podstawie filtru) /// </summary> /// <param name="filter">filtr do wyszukiwania /// <param name="mySql">Sql object.</param> /// <returns>read collection</returns> private static WLTableMessagesCollection DoReadAll(WLTableMessagesFilter filter, MySql mySql) { SqlQuery query = new SqlQuery("PA_WLTableMessages_SELALL", mySql); query.AddParam("@WLTableId", SqlDbType.BigInt, 0, filter.WLTableId, ParameterDirection.Input); query.AddParam("@WLTableId_RngLow", SqlDbType.BigInt, 0, filter.WLTableId_RngLow, ParameterDirection.Input); query.AddParam("@WLTableId_RngHigh", SqlDbType.BigInt, 0, filter.WLTableId_RngHigh, ParameterDirection.Input); query.AddParam("@BeachButlerMessage", SqlDbType.NVarChar, 200, filter.BeachButlerMessage, ParameterDirection.Input); query.AddParam("@BeachButlerMessage_LikeComp", SqlDbType.NVarChar, 200, filter.BeachButlerMessage_LikeComp, ParameterDirection.Input); query.AddParam("@TableGenieLeftButtonMessage", SqlDbType.NVarChar, 200, filter.TableGenieLeftButtonMessage, ParameterDirection.Input); query.AddParam("@TableGenieLeftButtonMessage_LikeComp", SqlDbType.NVarChar, 200, filter.TableGenieLeftButtonMessage_LikeComp, ParameterDirection.Input); query.AddParam("@TableGenieMiddleButtonMessage", SqlDbType.NVarChar, 200, filter.TableGenieMiddleButtonMessage, ParameterDirection.Input); query.AddParam("@TableGenieMiddleButtonMessage_LikeComp", SqlDbType.NVarChar, 200, filter.TableGenieMiddleButtonMessage_LikeComp, ParameterDirection.Input); query.AddParam("@TableGenieRightButtonMessage", SqlDbType.NVarChar, 200, filter.TableGenieRightButtonMessage, ParameterDirection.Input); query.AddParam("@TableGenieRightButtonMessage_LikeComp", SqlDbType.NVarChar, 200, filter.TableGenieRightButtonMessage_LikeComp, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId", SqlDbType.Int, 4, filter.WLDictChangeStatusId, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId_RngLow", SqlDbType.Int, 4, filter.WLDictChangeStatusId_RngLow, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId_RngHigh", SqlDbType.Int, 4, filter.WLDictChangeStatusId_RngHigh, ParameterDirection.Input); query.AddParam("@Ord__1", SqlDbType.TinyInt, 1, (byte)filter.Ord1, ParameterDirection.Input); query.AddParam("@Ord__2", SqlDbType.TinyInt, 1, (byte)filter.Ord2, ParameterDirection.Input); query.AddParam("@Ord__3", SqlDbType.TinyInt, 1, (byte)filter.Ord3, ParameterDirection.Input); return(MakeCollByQuery(query)); }
public static AuditLogListResponse List(string schema, AuditLogListRequest request) { var fld = IoC.Resolve <IAuditLogRow>(schema); SecurityHelper.EnsureLoggedIn(RightErrorHandling.ThrowException); var response = new AuditLogListResponse(); using (var connection = SqlConnections.New()) { response.Entities = new List <Row>(); var row = ((Row)fld).CreateNew(); if (request.Sort == null || request.Sort.Length == 0) { request.Sort = new SortBy[] { new SortBy(fld.DateField.Name, true) } } ; var query = new SqlQuery().From(row) .Select( (Field)fld.IdField, fld.EntityTypeIdField, fld.EntityIdField, fld.ParentTypeIdField, fld.OldParentIdField, fld.NewParentIdField, fld.DateField, (Field)fld.UserIdField, fld.AuditTypeIdField, fld.OldAuditDataField, fld.NewAuditDataField) .OrderBy( (Field)fld.IdField) .ApplySkipTakeAndCount(request.Skip, request.Take, request.ExcludeTotalCount) .ApplySort(request.Sort); if (request.EntityTypeId != null && request.EntityId != null) { var pEntityId = query.AddParam(request.EntityId); var pEntityTypeId = query.AddParam(request.EntityTypeId); query.Where(~( ~( new Criteria(0, fld.EntityTypeIdField) == pEntityTypeId & new Criteria(0, fld.EntityIdField) == pEntityId) | ~( new Criteria(0, fld.ParentTypeIdField) == pEntityTypeId & ~( new Criteria(0, fld.OldParentIdField) == pEntityId | new Criteria(0, fld.NewParentIdField) == pEntityId)))); } else { if (request.EntityTypeId != null) { query.WhereEqual(fld.EntityTypeIdField, request.EntityTypeId);//Convert.ToInt32(request.EntityTypeId.Value)); } if (request.EntityId != null) { query.WhereEqual(fld.EntityIdField, request.EntityId.Value); } } response.TotalCount = query.ForEach(connection, delegate() { response.Entities.Add(row.Clone()); }); response.SetSkipTakeTotal(query); response.IdNameLookups = new Dictionary <EntityType, Dictionary <long, string> >(); response.FieldTitles = new Dictionary <EntityType, Dictionary <string, string> >(); response.ForeignEntityTypes = new Dictionary <EntityType, Dictionary <string, string> >(); response.EntityTitles = new Dictionary <EntityType, string>(); var lookups = response.IdNameLookups; var titles = response.FieldTitles; var foreigns = response.ForeignEntityTypes; var entities = response.EntityTitles; Action <EntityType, Int64> addLookup = (entityType, id) => { Dictionary <long, string> lookup; if (!lookups.TryGetValue(entityType, out lookup)) { lookup = new Dictionary <long, string>(); lookups[entityType] = lookup; } if (!lookup.ContainsKey(id)) { lookup[id] = null; } }; Action <EntityType, string> addTitle = (entityType, field) => { Dictionary <string, string> lookup; if (!titles.TryGetValue(entityType, out lookup)) { lookup = new Dictionary <string, string>(); titles[entityType] = lookup; } if (!lookup.ContainsKey(field)) { lookup[field] = null; } }; Action <EntityType> addEntity = (entityType) => { if (!entities.ContainsKey(entityType)) { //Row r; String s = null; // TODO: FIX! //if (schema.TypeToTable.TryGetValue(entityType, out r)) // s = LocalText.TryGet(1055, "Db." + r.Table + ".EntitySingular", false); s = s ?? Enum.GetName(typeof(EntityType), entityType); entities[entityType] = s; } }; Action <EntityType, string, EntityType> addForeign = (entityType, field, foreignType) => { Dictionary <string, string> foreign; if (!foreigns.TryGetValue(entityType, out foreign)) { foreign = new Dictionary <string, string>(); foreigns[entityType] = foreign; } if (!foreign.ContainsKey(field)) { foreign[field] = Enum.GetName(typeof(EntityType), foreignType); } }; foreach (var entity in response.Entities) { addEntity(fld.EntityTypeIdField[entity]); addLookup(fld.EntityTypeIdField[entity], fld.EntityIdField[entity].Value); if (fld.ParentTypeIdField[entity] != null) { addEntity(fld.ParentTypeIdField[entity]); } //if (entity.UserId != null) // addLookup(UserRow.TableName, entity.UserId.Value); Row theRow; if (((AuditType?)fld.AuditTypeIdField[entity] == AuditType.Insert || (AuditType?)fld.AuditTypeIdField[entity] == AuditType.Update) && (fld.OldAuditDataField[entity] != null || fld.NewAuditDataField[entity] != null)) { theRow = RowRegistry.GetSchemaRow(RowRegistry.DefaultSchema, fld.EntityTypeIdField[entity]); if (theRow == null) { continue; } UpdateAuditDataDictionary ud = new UpdateAuditDataDictionary(); if (fld.OldAuditDataField[entity] != null) { ud.Old = JsonConvert.DeserializeObject <Dictionary <string, object> >(fld.OldAuditDataField[entity].TrimToNull() ?? "{}", JsonSettings.Tolerant); } if (fld.NewAuditDataField[entity] != null) { ud.New = JsonConvert.DeserializeObject <Dictionary <string, object> >(fld.OldAuditDataField[entity].TrimToNull() ?? "{}", JsonSettings.Tolerant); } for (var i = 0; i < 2; i++) { var d = (i == 0) ? ud.Old : ud.New; if (d != null) { foreach (var p in d) { addTitle(fld.EntityTypeIdField[entity], p.Key); if (p.Value != null && p.Value is Int16 || p.Value is Int32 || p.Value is Int64) { var f = theRow.FindField(p.Key); if (f != null && f.ForeignTable != null) { //EntityType foreignType; //if (schema.TableToType.TryGetValue(f.ForeignTable, out foreignType)) { addForeign(fld.EntityTypeIdField[entity], p.Key, f.ForeignTable); addLookup(f.ForeignTable, Convert.ToInt64(p.Value)); } } } } } } } } foreach (var pair in response.IdNameLookups) { Row entity = RowRegistry.GetSchemaRow(RowRegistry.DefaultSchema, pair.Key); if (entity != null) { var idRow = entity as IIdRow; var nameRow = entity as INameRow; if (idRow != null && nameRow != null) { var lookup = pair.Value; var idName = GetIdNameDictionary(connection, (IIdRow)entity, ((INameRow)entity).NameField, lookup.Keys); foreach (var p in idName) { lookup[p.Key] = p.Value; } } } } foreach (var pair in response.FieldTitles) { Row entity = RowRegistry.GetSchemaRow(RowRegistry.DefaultSchema, pair.Key); if (entity != null) { var lookup = pair.Value; var keys = new string[lookup.Keys.Count]; lookup.Keys.CopyTo(keys, 0); foreach (var key in keys) { Field f; if (key.EndsWith("Id")) { var s = key.Substring(0, key.Length - 2); f = entity.FindField(s); if (f != null) { lookup[key] = f.Title; continue; } } f = entity.FindField(key); if (f != null) { lookup[key] = f.Title; } } } } return(response); } }
/// <summary> /// Saves the specified dto. /// </summary> /// <param name="dto">The dto.</param> /// <param name="mySql">My SQL.</param> private static void DoSave(WLTableDto dto, MySql mySql) { bool isNew = dto.IsNew; string queryType = isNew ? "INS" : "UPD"; SqlQuery query = new SqlQuery("PA_WLTable_" + queryType, mySql); SqlParameter prmId = query.AddParam("@Id", SqlDbType.BigInt, 0, dto.Id, isNew ? ParameterDirection.Output : ParameterDirection.Input); query.AddParam("@Number", SqlDbType.NVarChar, 50, dto.Number, ParameterDirection.Input); query.AddParam("@WaiterWLEmployeeId", SqlDbType.BigInt, 0, dto.WaiterWLEmployeeId, ParameterDirection.Input); query.AddParam("@ManagerWLEmployeeId", SqlDbType.BigInt, 0, dto.ManagerWLEmployeeId, ParameterDirection.Input); query.AddParam("@WLLocationId", SqlDbType.BigInt, 0, dto.WLLocationId, ParameterDirection.Input); query.AddParam("@WLDictServiceDeviceId", SqlDbType.BigInt, 0, dto.WLDictServiceDeviceId, ParameterDirection.Input); query.AddParam("@BeachButlerWhoToPage", SqlDbType.BigInt, 0, dto.BeachButlerWhoToPage, ParameterDirection.Input); query.AddParam("@TGLeftButtonWhoToPage", SqlDbType.BigInt, 0, dto.TGLeftButtonWhoToPage, ParameterDirection.Input); query.AddParam("@TGMiddleButtonWhoToPage", SqlDbType.BigInt, 0, dto.TGMiddleButtonWhoToPage, ParameterDirection.Input); query.AddParam("@TGRightButtonWhoToPage", SqlDbType.BigInt, 0, dto.TGRightButtonWhoToPage, ParameterDirection.Input); query.AddParam("@SerialNo", SqlDbType.NVarChar, 20, dto.SerialNo, ParameterDirection.Input); query.AddParam("@WLTableId", SqlDbType.BigInt, 0, dto.WLTableId, ParameterDirection.Input); query.AddParam("@ClientId", SqlDbType.BigInt, 0, dto.ClientId, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId", SqlDbType.Int, 4, dto.WLDictChangeStatusId, ParameterDirection.Input); query.ExecuteStoreProc(); dto.Id = MyConvert.ToLong(prmId.Value); if (dto.IsNew) { dto.SetIsNew(false); } }
/// <summary> /// Odczyt kolekcji z SEL_ALL (na podstawie filtru) /// </summary> /// <param name="filter">filtr do wyszukiwania /// <param name="mySql">Sql object.</param> /// <returns>read collection</returns> private static WLTableCollection DoReadAll(WLTableFilter filter, MySql mySql) { SqlQuery query = new SqlQuery("PA_WLTable_SELALL", mySql); query.AddParam("@Id", SqlDbType.BigInt, 0, filter.Id, ParameterDirection.Input); query.AddParam("@Id_RngLow", SqlDbType.BigInt, 0, filter.Id_RngLow, ParameterDirection.Input); query.AddParam("@Id_RngHigh", SqlDbType.BigInt, 0, filter.Id_RngHigh, ParameterDirection.Input); query.AddParam("@Number", SqlDbType.NVarChar, 50, filter.Number, ParameterDirection.Input); query.AddParam("@Number_LikeComp", SqlDbType.NVarChar, 50, filter.Number_LikeComp, ParameterDirection.Input); query.AddParam("@WaiterWLEmployeeId", SqlDbType.BigInt, 0, filter.WaiterWLEmployeeId, ParameterDirection.Input); query.AddParam("@WaiterWLEmployeeId_RngLow", SqlDbType.BigInt, 0, filter.WaiterWLEmployeeId_RngLow, ParameterDirection.Input); query.AddParam("@WaiterWLEmployeeId_RngHigh", SqlDbType.BigInt, 0, filter.WaiterWLEmployeeId_RngHigh, ParameterDirection.Input); query.AddParam("@ManagerWLEmployeeId", SqlDbType.BigInt, 0, filter.ManagerWLEmployeeId, ParameterDirection.Input); query.AddParam("@ManagerWLEmployeeId_RngLow", SqlDbType.BigInt, 0, filter.ManagerWLEmployeeId_RngLow, ParameterDirection.Input); query.AddParam("@ManagerWLEmployeeId_RngHigh", SqlDbType.BigInt, 0, filter.ManagerWLEmployeeId_RngHigh, ParameterDirection.Input); query.AddParam("@WLLocationId", SqlDbType.BigInt, 0, filter.WLLocationId, ParameterDirection.Input); query.AddParam("@WLLocationId_RngLow", SqlDbType.BigInt, 0, filter.WLLocationId_RngLow, ParameterDirection.Input); query.AddParam("@WLLocationId_RngHigh", SqlDbType.BigInt, 0, filter.WLLocationId_RngHigh, ParameterDirection.Input); query.AddParam("@WLDictServiceDeviceId", SqlDbType.BigInt, 0, filter.WLDictServiceDeviceId, ParameterDirection.Input); query.AddParam("@WLDictServiceDeviceId_RngLow", SqlDbType.BigInt, 0, filter.WLDictServiceDeviceId_RngLow, ParameterDirection.Input); query.AddParam("@WLDictServiceDeviceId_RngHigh", SqlDbType.BigInt, 0, filter.WLDictServiceDeviceId_RngHigh, ParameterDirection.Input); query.AddParam("@BeachButlerWhoToPage", SqlDbType.BigInt, 0, filter.BeachButlerWhoToPage, ParameterDirection.Input); query.AddParam("@BeachButlerWhoToPage_RngLow", SqlDbType.BigInt, 0, filter.BeachButlerWhoToPage_RngLow, ParameterDirection.Input); query.AddParam("@BeachButlerWhoToPage_RngHigh", SqlDbType.BigInt, 0, filter.BeachButlerWhoToPage_RngHigh, ParameterDirection.Input); query.AddParam("@TGLeftButtonWhoToPage", SqlDbType.BigInt, 0, filter.TGLeftButtonWhoToPage, ParameterDirection.Input); query.AddParam("@TGLeftButtonWhoToPage_RngLow", SqlDbType.BigInt, 0, filter.TGLeftButtonWhoToPage_RngLow, ParameterDirection.Input); query.AddParam("@TGLeftButtonWhoToPage_RngHigh", SqlDbType.BigInt, 0, filter.TGLeftButtonWhoToPage_RngHigh, ParameterDirection.Input); query.AddParam("@TGMiddleButtonWhoToPage", SqlDbType.BigInt, 0, filter.TGMiddleButtonWhoToPage, ParameterDirection.Input); query.AddParam("@TGMiddleButtonWhoToPage_RngLow", SqlDbType.BigInt, 0, filter.TGMiddleButtonWhoToPage_RngLow, ParameterDirection.Input); query.AddParam("@TGMiddleButtonWhoToPage_RngHigh", SqlDbType.BigInt, 0, filter.TGMiddleButtonWhoToPage_RngHigh, ParameterDirection.Input); query.AddParam("@TGRightButtonWhoToPage", SqlDbType.BigInt, 0, filter.TGRightButtonWhoToPage, ParameterDirection.Input); query.AddParam("@TGRightButtonWhoToPage_RngLow", SqlDbType.BigInt, 0, filter.TGRightButtonWhoToPage_RngLow, ParameterDirection.Input); query.AddParam("@TGRightButtonWhoToPage_RngHigh", SqlDbType.BigInt, 0, filter.TGRightButtonWhoToPage_RngHigh, ParameterDirection.Input); query.AddParam("@SerialNo", SqlDbType.NVarChar, 20, filter.SerialNo, ParameterDirection.Input); query.AddParam("@SerialNo_LikeComp", SqlDbType.NVarChar, 20, filter.SerialNo_LikeComp, ParameterDirection.Input); query.AddParam("@WLTableId", SqlDbType.BigInt, 0, filter.WLTableId, ParameterDirection.Input); query.AddParam("@WLTableId_RngLow", SqlDbType.BigInt, 0, filter.WLTableId_RngLow, ParameterDirection.Input); query.AddParam("@WLTableId_RngHigh", SqlDbType.BigInt, 0, filter.WLTableId_RngHigh, ParameterDirection.Input); query.AddParam("@ClientId", SqlDbType.BigInt, 0, filter.ClientId, ParameterDirection.Input); query.AddParam("@ClientId_RngLow", SqlDbType.BigInt, 0, filter.ClientId_RngLow, ParameterDirection.Input); query.AddParam("@ClientId_RngHigh", SqlDbType.BigInt, 0, filter.ClientId_RngHigh, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId", SqlDbType.Int, 4, filter.WLDictChangeStatusId, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId_RngLow", SqlDbType.Int, 4, filter.WLDictChangeStatusId_RngLow, ParameterDirection.Input); query.AddParam("@WLDictChangeStatusId_RngHigh", SqlDbType.Int, 4, filter.WLDictChangeStatusId_RngHigh, ParameterDirection.Input); query.AddParam("@Ord__1", SqlDbType.TinyInt, 1, (byte)filter.Ord1, ParameterDirection.Input); query.AddParam("@Ord__2", SqlDbType.TinyInt, 1, (byte)filter.Ord2, ParameterDirection.Input); query.AddParam("@Ord__3", SqlDbType.TinyInt, 1, (byte)filter.Ord3, ParameterDirection.Input); return(MakeCollByQuery(query)); }
/// <summary> /// Creates a clone of the query. /// </summary> /// <returns>A cloned query.</returns> /// <remarks> /// Clones states like TrackAssignments, AssignedFields etc, /// creates a copy of Params dictionary /// </remarks> public SqlQuery Clone() { var clone = new SqlQuery { dialect = dialect, dialectOverridden = dialectOverridden, skip = skip, take = take, countRecords = countRecords, distinct = distinct, omitParens = omitParens, into = new List <object>(into), intoIndex = intoIndex, forXml = forXml, forJson = forJson, unionQuery = unionQuery, unionType = unionType, nextAutoParam = nextAutoParam }; Column s; for (int i = 0; i < columns.Count; i++) { s = columns[i]; var si = new Column(s.Expression, s.ColumnName, s.IntoRowIndex, s.IntoField); clone.columns.Add(si); } clone.from = new StringBuilder(from.ToString()); if (where != null) { clone.where = new StringBuilder(where.ToString()); } if (orderBy != null) { clone.orderBy = new List <string>(); clone.orderBy.AddRange(orderBy); } if (groupBy != null) { clone.groupBy = new StringBuilder(groupBy.ToString()); } if (having != null) { clone.having = new StringBuilder(having.ToString()); } if (parent != null) { clone.parent = parent; } else if (Params != null) { foreach (var pair in Params) { clone.AddParam(pair.Key, pair.Value); } } if (aliasExpressions != null) { clone.aliasExpressions = new Dictionary <string, string>( aliasExpressions, StringComparer.OrdinalIgnoreCase); } if (aliasWithJoins != null) { aliasWithJoins = new Dictionary <string, IHaveJoins>( aliasWithJoins, StringComparer.OrdinalIgnoreCase); } return(clone); }