/// <summary> /// An IQueryable<T> extension method that updates all rows from the query using an /// expression without retrieving entities. /// </summary> /// <typeparam name="T">The type of elements of the query.</typeparam> /// <param name="query">The query to update rows from without retrieving entities.</param> /// <param name="updateFactory">The update expression.</param> /// <param name="batchUpdateBuilder">The batch builder action to change default configuration.</param> /// <returns>The number of rows affected.</returns> public static int Update <T>(this IQueryable <T> query, Expression <Func <T, T> > updateFactory, Action <BatchUpdate> batchUpdateBuilder) where T : class { var batchUpdate = new BatchUpdate(); BatchUpdateManager.BatchUpdateBuilder?.Invoke(batchUpdate); batchUpdateBuilder?.Invoke(batchUpdate); return(batchUpdate.Execute(query, updateFactory)); }
/// <summary> /// An IQueryable<T> extension method that updates all rows from the query using an /// expression without retrieving entities. /// </summary> /// <typeparam name="T">The type of elements of the query.</typeparam> /// <param name="query">The query to update rows from without retrieving entities.</param> /// <param name="updateFactory">The update expression.</param> /// <param name="batchUpdateBuilder">The batch builder action to change default configuration.</param> /// <returns>The number of rows affected.</returns> public static int Update <T>(this IQueryable <T> query, Expression <Func <T, T> > updateFactory, Action <BatchUpdate> batchUpdateBuilder) where T : class { var batchUpdate = new BatchUpdate(); if (BatchUpdateManager.BatchUpdateBuilder != null) { BatchUpdateManager.BatchUpdateBuilder(batchUpdate); } if (batchUpdateBuilder != null) { batchUpdateBuilder(batchUpdate); } return(batchUpdate.Execute(query, updateFactory)); }