Like you, I created a class that has static methods in it so that I could centralize my creation of DataAccessAdapters and minize the "extra lines" in my BL code.
My personal preference is NOT to use a shared DataAccessAdapter instance, but instead create it as necessary.
Using the using statement is recommended so that you don't need to open, close and displose adapter objects.
public static bool DeleteEntity(IEntity2 entity)
{
bool status;
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
status = adapter.DeleteEntity(entity);
}
return status;
}
Then when you want to execute it in your BL code, you can do so as follows:
if (!DataManager.DeleteEntity(_Trailer))
{
throw new Exception("An error occured while attempting to delete this entity", null);
}
You don't need an instance of _data since the DeleteEntity method is static.
ps. check out the "code" tags in the forum to post formatted code.