示例#1
0
        private IEnumerable <T> Insert <T>(IEnumerable <T> entities, Model.InsertStatementModel <T> model) where T : ITable
        {
            var command = _connection.CreateCommand();

            foreach (var entity in entities)
            {
                command.CommandText = model.ApplyParameters(entity);
                _connector.PreInsert <T>(command, entity);
                command.ExecuteScalar();
                _connector.PostInsert <T>(command, entity);
            }
            return(entities);
        }
示例#2
0
        private IEnumerable <T> Insert <T>(IEnumerable <T> entities, Model.InsertStatementModel <T> model, Func <T, T> onTransform = null)
        {
            var command = _transaction.Connection.CreateCommand();

            if (onTransform == null)
            {
                onTransform = instance => instance;
            }

            foreach (var _entity in entities)
            {
                var entity = onTransform(_entity);
                command.CommandText = model.GetSql(entity);
                _transaction.Connector.PreInsert <T>(command, entity, model.IsFull);
                command.ExecuteScalar();
                _transaction.Connector.PostInsert <T>(command, entity, model.IsFull);
            }
            return(entities);
        }