I have an entity called Person who has a collection of addresses.
I created:
public partial class Person
{
public int AddressCount{get{return Addresses.Count;}}
}
This returns the error:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
I am returning a collection of people, how can I do this without doing this:
public int AddressCount
{
get
{
using (var c = new Entities())
{
return c.People.Where(s => s.PersonId == PersonId).Single().Addresses.Count;
}
}
}