实体框架核心6多到许多关系导航属性排除

发布于 2025-02-02 19:16:04 字数 453 浏览 3 评论 0原文

我有两个链接的实体,这些实体具有多一到多的关系,如下所示:

public class Product
{
    //Omitted code...
    public virtual ICollection<Ingredient> ingredients { get; set; }
}

public class Ingredient
{
    // Omitted code...
    public virtual ICollection<Product> products { get; set; }
}

我的问题是:我只想加载product。关系的侧面是impodient.products。我想保持多一的关系。如何防止Intredient.products导航属性被加载?

提前致谢

I have two entities linked that have a many-to-many relationship as shown here:

public class Product
{
    //Omitted code...
    public virtual ICollection<Ingredient> ingredients { get; set; }
}

public class Ingredient
{
    // Omitted code...
    public virtual ICollection<Product> products { get; set; }
}

My question is: I want to load only Product.ingredients navigation property, and I don't want to load the other side of the relation which is ingredient.Products. I want to keep the many-to-many relationship. How can I prevent the ingredient.Products navigation property from being loaded ?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文