コード例 #1
0
        internal MySqlCommand BuildUpdateCommand <TSource, TTarget>(DataSet <TSource> source, DbTable <TTarget> target, Action <ColumnMapper, TSource, TTarget> columnMapper, CandidateKey targetKey)
            where TSource : class, IEntity, new()
            where TTarget : class, IEntity, new()
        {
            var import    = BuildImportQuery(source);
            var join      = import.Model.PrimaryKey.UnsafeJoin(targetKey);
            var statement = target.BuildUpdateStatement(import, columnMapper, join);

            return(GetUpdateCommand(statement));
        }
コード例 #2
0
        internal static MySqlCommand MockUpdate <T>(this DbTable <T> dbTable, int rowsAffected, Action <ColumnMapper, T> columnMapper, Func <T, _Boolean> where = null)
            where T : Model, new()
        {
            var columnMappings = dbTable.Verify(columnMapper, nameof(columnMapper));
            var statement      = dbTable.BuildUpdateStatement(columnMappings, where);
            var result         = dbTable.MySqlSession().GetUpdateCommand(statement);

            dbTable.UpdateOrigin(null, rowsAffected);
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Builds UPDATE query statement.
        /// </summary>
        /// <param name="target">The target DbTable.</param>
        /// <param name="source">The source DbTable.</param>
        /// <param name="columnMapper">Provides column mappings between source and target DbTables.</param>
        /// <param name="keyMappings">Key mappings between source and target DbTables.</param>
        /// <returns>The query statement</returns>
        public static DbSelectStatement BuildUpdateStatement <TSource, TTarget>(this DbTable <TTarget> target, DbSet <TSource> source,
                                                                                Action <ColumnMapper, TSource, TTarget> columnMapper, IReadOnlyList <ColumnMapping> keyMappings)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            target.VerifyNotNull(nameof(target));
            source.VerifyNotNull(nameof(source));
            columnMapper.VerifyNotNull(nameof(columnMapper));
            Verify(keyMappings, nameof(keyMappings), source.Model, target.Model);

            return(target.BuildUpdateStatement(source, columnMapper, keyMappings));
        }
コード例 #4
0
        internal static MySqlCommand MockUpdate <TSource, TTarget>(this DbTable <TTarget> dbTable, int rowsAffected, DbSet <TSource> dbSet,
                                                                   Action <ColumnMapper, TSource, TTarget> columnMapper, Func <TSource, TTarget, KeyMapping> join)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            dbTable.Verify(dbSet, nameof(dbSet));
            var columnMappings = dbTable.Verify(columnMapper, nameof(columnMapper), dbSet._);
            var keyMapping     = dbTable.Verify(join, nameof(join), dbSet._).GetColumnMappings();
            var statement      = dbTable.BuildUpdateStatement(dbSet, columnMappings, keyMapping);
            var result         = dbTable.MySqlSession().GetUpdateCommand(statement);

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