Ejemplo n.º 1
0
        public override string BuildUpdateStatement(string tableName,
                                                    ICollection <string> fields,
                                                    string primaryKeyField)
        {
            // updatable fields:
            StringBuilder builder         = new StringBuilder();
            var           updatableFields = this.GetFieldAndParameterBasedFieldCollection(fields);

            foreach (var updatableField in updatableFields)
            {
                if (updatableField.Key == primaryKeyField)
                {
                    continue;
                }
                builder.Append(string.Format("{0} = {1}{2}",
                                             updatableField.Key,
                                             updatableField.Value,
                                             FIELD_DELIMITER));
            }

            var forUpdate = builder.ToString().TrimEnd(FIELD_DELIMITER.ToCharArray());

            string update = string.Format("UPDATE [{0}] SET {1} {2}",
                                          tableName,
                                          forUpdate,
                                          this.BuildWhereClauseById(tableName,
                                                                    primaryKeyField,
                                                                    string.Concat(FIELD_PARAMETER_DELIMITER, primaryKeyField)));

            return(update);
        }
Ejemplo n.º 2
0
        private string GetCommaSeparatedFieldNames(ICollection <string> fields)
        {
            StringBuilder builder = new StringBuilder();

            new List <string>(fields).ForEach(field => builder.Append(string.Concat(field, FIELD_DELIMITER)));
            string fieldList = builder.ToString().TrimEnd(FIELD_DELIMITER.ToCharArray());

            return(fieldList);
        }