我的 EF 对象查询是:
from customer in MCDBContext.Customers
join customerCase in MCDBContext.CustomerCases on customer.CustomerID equals customerCase.CustomerID
join customerCasePhone in MCDBContext.CustomerCasePhones on customerCase.CustomerCaseID equals customerCasePhone.CustomerCaseID
**join customerCaseAddress in MCDBContext.CustomerCaseAddresses on customerCase.CustomerCaseID equals customerCaseAddress.CustomerCaseID**
where customer.CustomerPIN.Equals(pin, StringComparison.InvariantCultureIgnoreCase) &&
customerCasePhone.PhoneNumber.Equals(phoneNumber, StringComparison.InvariantCultureIgnoreCase) &&
**customerCaseAddress.AddressTypeID == 6** &&
customerCase.IsActive == true && customerCasePhone.IsActive == true && customerCaseAddress.Active == true && customer.IsActive == true
select customer;
在代码中:
var customers = getmethod() //calls the above object query method.
现在当我这样做时customers.First().CustomerAddresses();
//返回所有客户地址,尽管我在我的对象查询中过滤它只做 TypeID = 6。为什么这样?我不想再写过滤条件。有任何想法吗?
谢谢。