Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for BulkInsert and InsertFrom #33

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
25 changes: 25 additions & 0 deletions Source/EntityFramework.Extended/Batch/IBatchRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,30 @@ int Delete<TEntity>(ObjectContext objectContext, EntityMap entityMap, ObjectQuer
/// <returns>The number of rows updated.</returns>
int Update<TEntity>(ObjectContext objectContext, EntityMap entityMap, ObjectQuery<TEntity> query, Expression<Func<TEntity, TEntity>> updateExpression)
where TEntity : class;

/// <summary>
/// Create and runs a batch insert statement.
/// </summary>
/// <typeparam name="TEntity">The type of the entity to be inserted</typeparam>
/// <param name="objectContext">The <see cref="ObjectContext"/> to get connection and metadata information from.</param>
/// <param name="entityMap">The <see cref="EntityMap"/> for <typeparamref name="TEntity"/>.</param>
/// <param name="records">Collection of <typeparamref name="TEntity"/> to be inserted</param>
/// <returns>The number of rows inserted.</returns>
int BulkInsert<TEntity>(ObjectContext objectContext, EntityMap entityMap, IEnumerable<TEntity> records)
where TEntity : class;

/// <summary>
/// Create and runs a batch insert from statement.
/// </summary>
/// <typeparam name="TSource">The type of the source entity.</typeparam>
/// <typeparam name="TEntity">The type of the entity to be inserted.</typeparam>
/// <param name="destinationContext">The <see cref="ObjectContext"/> to get connection and metadata information from.</param>
/// <param name="destinationEntityMap">The <see cref="EntityMap"/> for <typeparamref name="TEntity"/>.</param>
/// <param name="sourceQuery">The query from which to get the <typeparamref name="TSource"/> entities.</param>
/// <param name="mappingExpression">The insert expression mapping <typeparamref name="TSource"/> to <typeparamref name="TEntity"/></param>
/// <returns>The number of rows inserted.</returns>
int InsertFrom<TSource, TEntity>(ObjectContext destinationContext, EntityMap destinationEntityMap, ObjectQuery<TSource> sourceQuery, Expression<Func<TSource, TEntity>> mappingExpression)
where TEntity : class
where TSource : class;
}
}
Loading