相关疑难解决方法(0)

EF Core Second level ThenInclude missworks

假设首先使用这些模型:

Method有一个OriginalCode OriginalCode有很多Mutants Mutant有很多ParseSubTrees的

现在在查询时Method我希望另一个被加载.所以我有以下内容:

Method targetMethod = dBContext.Methods
            .Include(me => me.OriginalCode)
                .ThenInclude(oc => oc.Mutants)
            .FirstOrDefault(me => me.Id == id);
Run Code Online (Sandbox Code Playgroud)

并且下一步是另外包括ParseSubTree.但问题是我无法访问它.请参见以下图像:

mu是除对象引用之外的列表

问题是"mu是列表而不是对象引用"!

我的错误在哪里!

TG.

entity-framework include entity-framework-core .net-core

18
推荐指数
1
解决办法
2866
查看次数

然后包含不适用于实体框架LINQ查询

我有一个这样的数据库模型:

public class Customer
{
    public int CustomerId{ get; set; }

    public int OrderId { get; set; }
    public ICollection<Order> Orders { get; set; }
}

public class Order
{
    public int OrderId { get; set; }
    public int Amount { get; set; }

    public int ProductId { get; set; }
    public Product Product { get; set; }
}

public class Product
{
    public int ProductId { get; set; }
    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

因此,我们有一个可以下订单的客户。该订单包括产品,其中包括名称。我现在正尝试使用linq语句返回完整的模型,如下所示:

_db.Customer.Include(c …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework-core

5
推荐指数
1
解决办法
5765
查看次数