Пример #1
0
        private void GetColumnsAndValues(out StringBuilder columns, out StringBuilder values, params DbField[] skipFields)
        {
            columns = new StringBuilder();
            values  = new StringBuilder();
            List <DbField> fields = new List <DbField> ();

            foreach (List <DbColumnManager> managersList in columnManagers)
            {
                foreach (DbColumnManager manager in managersList)
                {
                    bool skip = skipFields.Any(field => manager.DbField == field);

                    if (skip)
                    {
                        continue;
                    }

                    if (fields.Contains(manager.DbField))
                    {
                        continue;
                    }

                    if (columns.Length > 0)
                    {
                        columns.Append(", ");
                        values.Append(", ");
                    }

                    columns.Append(fTrans.GetFieldName(manager.DbField));
                    values.Append(TimeStamps.Contains(manager.DbField) && updateTimeStamp ?
                                  CurrentDateTimeFunction : fTrans.GetParameterName(manager.DbField));
                    fields.Add(manager.DbField);
                }
            }
        }
Пример #2
0
        public string GetSetStatement(params DbField [] skipFields)
        {
            StringBuilder  ret    = new StringBuilder();
            List <DbField> fields = new List <DbField> ();

            foreach (List <DbColumnManager> managersList in columnManagers)
            {
                foreach (DbColumnManager manager in managersList)
                {
                    if (skipFields.Any(field => manager.DbField == field))
                    {
                        continue;
                    }

                    if (fields.Contains(manager.DbField))
                    {
                        continue;
                    }

                    ret.Append(ret.Length == 0 ? " SET " : ", ");

                    string fieldName = fTrans.GetFieldName(manager.DbField);
                    if (TimeStamps.Contains(manager.DbField) && updateTimeStamp)
                    {
                        ret.AppendFormat("{0} = {1}", fieldName, CurrentDateTimeFunction);
                    }
                    else
                    {
                        string paramName = fTrans.StripQuotationChars(fieldName);
                        ret.AppendFormat("{0} = @{1}", fieldName, paramName);
                    }
                    fields.Add(manager.DbField);
                }
            }

            return(ret.ToString());
        }