Beispiel #1
0
        public List <DBColumnValue> GetColumnValuesEscaped()
        {
            ColumnSet            columnSet = TableRecord.GetColumnSet(this.GetType());
            List <DBColumnValue> values    = new List <DBColumnValue>();

            foreach (DBColumnAttribute attrib in columnSet)
            {
                values.Add(new DBColumnValue(DatabaseHelper.DBEscape(this.GetType().GetProperty(attrib.PropertyName).GetValue(this)), attrib));
            }

            return(values);
        }
Beispiel #2
0
        protected static SqlCommand GenerateInsert(DBConnection connection, string tableName, TableRecord record)
        {
            List <DBColumnValue> values = record.GetColumnValuesEscaped();
            string bindedVariables      = DatabaseHelper.GenerateBindedVariables(values.Count);

            SqlCommand command = connection.GetCommand(String.Format("INSERT INTO {0} VALUES({1})", tableName, bindedVariables));

            for (int i = 0; i < values.Count; i++)
            {
                command.Parameters.Add(DatabaseHelper.GetBoundVariableByIndex(i), values[i].Attribute.DbType, values[i].Attribute.Size).Value = values[i].Value;
            }

            command.Prepare();

            return(command);
        }