I just started using code contracts in my project. However, I had 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 in which there are no organizations in the database.
However, this is not the case, according to CodeContracts, which give me an error: "requires unproven: source! = Null"
What is he trying to tell me? I can satisfy code contracts using Contract.Assume, assuming it will always find something, but then I need to do this in all methods that read data from the database.
Am I missing something, or is this the intended behavior when you work with databases and LINQ?
source
share