我有IDisposable Business class: 私人o_Entities上下文;
public o_Entities GetContext()
{
if (context == null)
context = new o_Entities();
return context;
}
public List<SModel> List(int s_id)
{
var currentContext = GetContext();
var s = (from c in currentContext.tS
where (s_id == 0 || s_id == null || (c.s_id == s_id))
orderby c.s_id ascending
select new SModel
{
s_id = c.s_id,
s_name = c.s_name,
address = c.address,
phone = c.phone.Trim()
});
return s.ToList();
}
private bool dispos = false;
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
context.Dispose();
}
}
this.disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
我在Dispose()函数上设置了断点,但从未调用它。有什么不对吗?
谢谢。