I have a class I'm using to handle all my DB interaction. Basically when an instance of this class is created it creates an instance of the model, which will persist until the DataAccess object is out of scope.
public class DataAccess
{
ModelContainer model;
public DataAccess()
{
model = new ModelContainer();
}
public void Close()
{
if (model != null)
{
model.Connection.Close();
model.Dispose();
}
}
}
What cleanup do I need to preform on the model? I've cought my self forgetting to call my Close()
method when writing my unit tests. I like the using(DataAccess data = new DataAccess())
way of dealing with DB objects like you use in LINQ to SQL, so should I make DataAccess implement iDisposeable?