Since there is no DeleteAllOnSubmit() method for LINQ to Entities. So I myself create it and named for DeleteAllObjects as following code.
public static void DeleleAllObjects<TEntity>(this ObjectSet<TEntity> objectSet, TEntity[] objects)
{
foreach(var o in objects)
{
objectSet.DeleteObject(o);
}
}
However the code I write fail on compile and get the error message:
The type ‘TEntity’ must be a reference type in order to use it as
parameter ‘TEntity’ in the generic type or method
I think use foreach with DeleteObject all the time is not a good idea for delete collection.
Try this. The method needs to be a generic,
TEntityis simply the placeholder for the type.