Passing IDbSet to generic method
I'm sure this is pretty basic but I have trouble constructing generic
methods. I have numerous interfaces declared in my DBContext class
(IDbSet, IDbSet, etc.). I want to pass them into a method that will
process them. In this case by deleting records. This is what I tried to do
but I can't figure out how to create the method signature.
private static void EmptyTable<T>(ContactContext context, T records)
{
foreach (var record in records)
{
records.Remove(record);
}
context.SaveChanges();
}
No comments:
Post a Comment