table 加入的实体框架导航 属性

Entity Frame Navigation property for table joins

我有 3 个表,即 Ship[ShipID, Name, YearOfConstr, CompanyID(FK), TypeID(FK)],它是 Company[CompanyID, Name, Headquarter] 和 Type[TypeID, Description, NoPassengers] 之间的桥梁

我想查询具有特定类型 = "xxx" 且总部 = "yyy"

的所有公司的名称

下面是我试过的方法,但它没有返回任何内容,也不会抛出错误。

public List<string> AllShippingCompanies(string TypeDescription, string headquarters)
{

    var list = from shipcomany in dbContext.Ships.Where(x => x.Type.Description == TypeDescription && x.ShippingCompany.Headquarter == headquarters)
               select shipcomany.ShippingCompany.Name;


    return list.ToList();
}

我可能做错了什么?

刚查了一下,我的数据库里没有相关数据。该代码工作正常。这是正确的。感谢您的宝贵时间