Пример #1
0
        internal MySqlCommand BuildInsertCommand <TSource, TTarget>(DataSet <TSource> source, DbTable <TTarget> target, Action <ColumnMapper, TSource, TTarget> columnMapper)
            where TSource : class, IEntity, new()
            where TTarget : class, IEntity, new()

        {
            var import    = BuildImportQuery(source);
            var statement = target.BuildInsertStatement(import, columnMapper);

            return(GetInsertCommand(statement));
        }
Пример #2
0
        internal SqlCommand BuildInsertCommand <TSource, TTarget>(DataSet <TSource> source, DbTable <TTarget> target,
                                                                  Action <ColumnMapper, TSource, TTarget> columnMapper, IDbTable identityOutput)
            where TSource : Model, new()
            where TTarget : Model, new()

        {
            var import    = BuildImportQuery(source);
            var statement = target.BuildInsertStatement(import, columnMapper);

            return(GetInsertCommand(statement, identityOutput));
        }
Пример #3
0
        /// <summary>
        /// Builds INSERT query statement.
        /// </summary>
        /// <typeparam name="TSource">Entity type of source DbSet.</typeparam>
        /// <typeparam name="TTarget">Entity type of target DbTable.</typeparam>
        /// <param name="target">The target DbTable.</param>
        /// <param name="source">The source DbSet.</param>
        /// <param name="columnMapper">Provides column mappings between source DbSet and target DbTable.</param>
        /// <returns>The query statement.</returns>
        public static DbSelectStatement BuildInsertStatement <TSource, TTarget>(this DbTable <TTarget> target, DbSet <TSource> source,
                                                                                Action <ColumnMapper, TSource, TTarget> columnMapper)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            target.VerifyNotNull(nameof(target));
            source.VerifyNotNull(nameof(source));
            var columnMappings = target.Verify(columnMapper, nameof(columnMapper), source._);

            return(target.BuildInsertStatement(source, columnMappings));
        }
Пример #4
0
        /// <summary>
        /// Builds INSERT query statement.
        /// </summary>
        /// <typeparam name="TSource">Entity type of source DbSet.</typeparam>
        /// <typeparam name="TTarget">Entity type of target DbTable.</typeparam>
        /// <param name="target">The target DbTable.</param>
        /// <param name="source">The source DbSet.</param>
        /// <param name="columnMappings">Column mappings between source DbSet and target DbTable.</param>
        /// <returns>The query statement.</returns>
        public static DbSelectStatement BuildInsertStatement <TSource, TTarget>(this DbTable <TTarget> target, DbSet <TSource> source,
                                                                                IReadOnlyList <ColumnMapping> columnMappings)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            target.VerifyNotNull(nameof(target));
            source.VerifyNotNull(nameof(source));
            Verify(columnMappings, nameof(columnMappings), source.Model, target.Model);

            return(target.BuildInsertStatement(source, columnMappings));
        }
Пример #5
0
        public static SqlCommand MockInsert <TSource, TTarget>(this DbTable <TTarget> dbTable, int rowsAffected, DbSet <TSource> source, Action <ColumnMapper, TSource, TTarget> columnMapper)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            dbTable.Verify(source, nameof(source));
            var columnMappings = dbTable.Verify(columnMapper, nameof(columnMapper), source._);

            var result = dbTable.GetInsertCommand(dbTable.BuildInsertStatement(source, columnMappings));

            dbTable.UpdateOrigin(source, rowsAffected);
            return(result);
        }