Skip to content

Instantly share code, notes, and snippets.

@karthik25
Created May 5, 2013 04:28
Show Gist options
  • Select an option

  • Save karthik25/5519699 to your computer and use it in GitHub Desktop.

Select an option

Save karthik25/5519699 to your computer and use it in GitHub Desktop.
This is a fluent extension that adds RemoveAll method to IDbSet<T>
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
namespace MyApp.Domain.FluentExtensions
{
public static class DbSetFluentExtensions
{
public static IEnumerable<T> RemoveAll<T>(this IDbSet<T> src, IEnumerable<T> list)
where T : class
{
var items = list.ToList();
foreach (var instance in items)
{
src.Remove(instance);
}
return items;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment