I use Code first EntityFramework 5 in my project. I came across a strange problem. My code is as follow:
public IQueryable<Company> Companies
{
get
{
return context.Companies.Include("BankAccounts").Include("CompanyContacts").Include("MyClients").Include("MyCompanies");
}
}
and method for calling some Companies:
public IQueryable<Company> GetMyCompaniesByUserId(Guid userId)
{
var obj = context.Companies.Include("BankAccounts");
//Thread.Sleep(1000);
var companeies = from c in obj
from myc in context.MyCompanies
where c.IsDelete == false && myc.UserId == userId && c.CompanyId == myc.CompanyId
select c;
return companeies;
}
Problem is that When I call GetMyCompaniesByUserId() method the bankaccounts is null, but when I debug this code step by step it works. I don't have any idea about problem. Please, help me. Thank in advance.