コード例 #1
0
        internal static MySqlCommand MockDelete <T>(this DbTable <T> dbTable, int rowsAffected, Func <T, _Boolean> where)
            where T : Model, new()
        {
            dbTable.UpdateOrigin(null, rowsAffected);
            var statement = dbTable.BuildDeleteStatement(where);

            return(dbTable.MySqlSession().GetDeleteCommand(statement));
        }
コード例 #2
0
        internal MySqlCommand BuildDeleteCommand <TSource, TTarget>(DataSet <TSource> source, DbTable <TTarget> target, CandidateKey targetKey)
            where TSource : class, IEntity, new()
            where TTarget : class, IEntity, new()
        {
            var keys           = BuildImportKeyQuery(source);
            var columnMappings = keys._.PrimaryKey.UnsafeJoin(targetKey);
            var statement      = target.BuildDeleteStatement(keys, columnMappings);

            return(GetDeleteCommand(statement));
        }
コード例 #3
0
        /// <summary>
        /// Builds DELETE 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="keyMappings">Key mappings between source and target DbTables.</param>
        /// <returns>The query statement</returns>
        public static DbSelectStatement BuildDeleteStatement <TSource, TTarget>(this DbTable <TTarget> target, DbSet <TSource> source, IReadOnlyList <ColumnMapping> keyMappings)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            target.VerifyNotNull(nameof(target));
            source.VerifyNotNull(nameof(source));
            Verify(keyMappings, nameof(keyMappings), source.Model, target.Model);

            return(target.BuildDeleteStatement(source, keyMappings));
        }
コード例 #4
0
        internal static MySqlCommand MockDelete <TSource, TTarget>(this DbTable <TTarget> dbTable, int rowsAffected, DbSet <TSource> source, Func <TSource, TTarget, KeyMapping> keyMapper)
            where TSource : Model, new()
            where TTarget : Model, new()
        {
            var keyMapping = dbTable.Verify(keyMapper, nameof(keyMapper), source._);

            dbTable.UpdateOrigin(source, rowsAffected);
            var statement = dbTable.BuildDeleteStatement(source, keyMapping.GetColumnMappings());

            return(dbTable.MySqlSession().GetDeleteCommand(statement));
        }