Skip to content

Commit 88fac80

Browse files
committed
Implemented IRepository.DeleteRange() method
1 parent 5e604b6 commit 88fac80

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/Libraries/SmartStore.Core/Data/IRepository.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public partial interface IRepository<T> where T : BaseEntity
6767
/// <remarks>Implementors should delegate this to the current <see cref="IDbContext" /></remarks>
6868
void Delete(T entity);
6969

70+
/// <summary>
71+
/// Marks existing entities to be deleted from the store.
72+
/// </summary>
73+
/// <param name="entities">A list of entity instances that should be deleted from the database.</param>
74+
/// <remarks>Implementors should delegate this to the current <see cref="IDbContext" /></remarks>
75+
void DeleteRange(IEnumerable<T> entities);
76+
7077
[Obsolete("Use the extension method from 'SmartStore.Core, SmartStore.Core.Data' instead")]
7178
IQueryable<T> Expand(IQueryable<T> query, string path);
7279

src/Libraries/SmartStore.Data/EfRepository.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,24 @@ public void Delete(T entity)
158158
{
159159
this.Entities.Attach(entity);
160160
}
161-
161+
162162
this.Entities.Remove(entity);
163163

164164
if (this.AutoCommitEnabled)
165165
_context.SaveChanges();
166166
}
167167

168+
public void DeleteRange(IEnumerable<T> entities)
169+
{
170+
if (entities == null)
171+
throw new ArgumentNullException("entities");
172+
173+
this.Entities.RemoveRange(entities);
174+
175+
if (this.AutoCommitEnabled)
176+
_context.SaveChanges();
177+
}
178+
168179
[Obsolete("Use the extension method from 'SmartStore.Core, SmartStore.Core.Data' instead")]
169180
public IQueryable<T> Expand(IQueryable<T> query, string path)
170181
{

0 commit comments

Comments
 (0)