As far as I see ITable<T>
interface doesn't have DeleteAllOnSubmit()
method that exists in ITable
interface and in Table<T>
class.
I am going to implement on my own something like this:
public static void DeleteAllOnSubmit<T>(this ITable<T> table, IEnumerable<T> entities)
{
entities.ForEach(entity=>table.DeleteOnSubmit(entity);
}
Question 1: Is there any pitfalls here? If it was so easy Microsoft would implement that thierselves...
Question 2: Why that was not implmemented out-of-the box?
Having a look at the implementation of Table<TEntity>.DeleteAllOnSubmit<TSubEntity>()
shows, that there isn't much more going on:
public void DeleteAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity> entities) where TSubEntity: TEntity
{
if (entities == null)
{
throw Error.ArgumentNull("entities");
}
this.CheckReadOnly();
this.context.CheckNotInSubmitChanges();
this.context.VerifyTrackingEnabled();
foreach (TEntity local in entities.ToList<TSubEntity>())
{
this.DeleteOnSubmit(local);
}
}
So, I'd say: Your implementation is just fine.
BTW: There is no ForEach
extension method for IEnumerable<T>
.