Below is code I use in a WCF Service Reference I'm building using the Entity Framework. As you can see, right now I'm using the same code over and over again. Is there a syntax that will allow me to replace the entities with a generic type or another such method that would cut down on the amount of code being used?
var aI = (from AgentIdentification s in _db.AgentIdentification
where s.SymetraNumber == sNum
select s);
foreach (var record in aI)
{
_db.AgentIdentification.DeleteObject(record);
}
_db.SaveChanges();
var aG = (from Agent s in _db.Agent
where s.SymetraNumber == sNum
select s);
foreach (var record in aG)
{
_db.Agent.DeleteObject(record);
}
_db.SaveChanges();