In my application, I use Spring.Net for IoC. Service objects are called from ASP.Net files to perform CRUD operations using this service object. For example, I have a CustomerService to perform all CRUD operations in the Customer table. I use entity structure and entities are injected .. my question is where can I call the dispose method?
As far as I understood from the API documentation, if I don't call Dispose (), there is no guarantee that this will be garbage collection! So where and how to do it?
Service class example:
public class CustomerService
{
public ecommEntities entities = {get; set;}
public bool AddCustomer(Customer customer)
{
try
{
entities.AddToCustomer(customer);
entities.SaveChanges();
return true;
}
catch (Exception e)
{
log.Error("Error occured during creation of new customer: " + e.Message + e.StackTrace);
return false;
}
}
public bool UpdateCustomer(Customer customer)
{
entities.SaveChanges();
return true;
}
public bool DeleteCustomer(Customer customer)
.
.
.
And I just create a CustomerService object in a partial ASP class and call the necessary methods.
Thanks in advance for best practice and ideas.
Hi,
Abdel Rauf
source
share