I just started using code contracts in my project. However, I have a problem with my repository implementation, which queries my database using the Entity Framework.
I have the following method:
public IEnumerable<Organization> GetAllOrganizations()
{
return _uow.CreateSet<Party>().OfType<Organization>().AsEnumerable();
}
The method returns a collection containing all organizations in the database, or an empty collection there's not organizations in the database.
However, this is not okay according to CodeContracts, which give me the error: "requires unproven: source != null"
What is it trying to tell me? I can satisfy code contracts by using Contract.Assume, to assume that it would always find something, but then I need to do that in all methods that reads data from the database.
Am I missing something here, or is it intended behavior when you're working with databases and LINQ?