I am re-factoring a model class into an interface. The model class is auto-generated with Linq-to-Sql.
class FooRepository
{
// ...
public void Add(IFoo foo)
{
db.Foos.InsertOnSubmit(foo);
}
}
The InsertOnSubmit method takes an instance of Foo, not an IFoo. I can cast the instance inline to (Foo) and this works, but is there a cleaner way to do this?
I am already using StructureMap, can I add an attribute to the Add method to resolve the type based on my mappings?
Or can I override any of the model classes methods, or use the partial events to accomplish this?