What behavior should I use for a provider pattern with entity framework?
public class TestProvider : IDisposable
{
public Entities entities = new Entities();
public IEnumerable<Tag> GetAll()
{
return entities.Tag.ToList();
}
public ...
#region IDisposable Members
public void Dispose()
{
entities.Dispose();
}
#endregion
}
Or is it ok to use:
public class TestProvider
{
public IEnumerable<Tag> GetAll()
{
using (var entities = new Entities())
{
return entities.Tag.ToList();
}
}
public ...
}
Does it implies on performance? What are the pros and cons about it?