示例#1
0
        protected virtual DataSeedOperation CreateCommand(object[] values)
        {
            var ret = new DataSeedOperation();

            ret.Sql = string.Format("INSERT INTO {0} ({1}) Values(@{2})",
                                    _tableName, string.Join(",", _columns), string.Join(",@", _columns));

            ret.Prms = new Dictionary <string, object>(_columns.Length);
            for (var k = 0; k < _columns.Length; k++)
            {
                ret.Prms.Add(_columns[k], values[k]);
            }
            return(ret);
        }
示例#2
0
        protected virtual DataSeedOperation CreateCommand(object keyValue, params object[] values)
        {
            var ret = new DataSeedOperation();

            var sqlBuilder = new StringBuilder(string.Format("UPDATE {0} SET", _tableName));

            foreach (var column in _columns)
            {
                sqlBuilder.AppendFormat(" {0} = @{0},", column);
            }
            ret.Sql = sqlBuilder.ToString(0, sqlBuilder.Length - 1) + string.Format(" WHERE {0} = @{0}", _keyColumn);

            ret.Prms = new Dictionary <string, object>(_columns.Length);
            for (var k = 0; k < _columns.Length; k++)
            {
                ret.Prms.Add(_columns[k], values[k]);
            }
            ret.Prms.Add(_keyColumn, keyValue);

            return(ret);
        }
示例#3
0
 internal void AddDataOperation(DataSeedOperation dataOperation)
 {
     _dataOperations.Add(dataOperation);
 }