簡體   English   中英

EntityFramework CORE-Plus 中的 IncludeFilter 不過濾包含的記錄

[英]IncludeFilter in EntityFramework CORE-Plus not filtering the included record

將下面的 Linq 查詢與 Entity Framework Core 3 和 EntityFramework Core Plus 庫一起使用,我希望我會返回 1 因子,其中 IsActive boolean 設置為 true 的所有項目。 相反,我得到的是 1 Factor 和 IsActive 值是真還是假的所有項目。 為什么?

public class Factor 
    {
        public Factor()
        {
            Items = new List<Item>();
        }
        public bool IsActive{ get; set; }
        public int FactorId { get; set; }
        public virtual ICollection<Item> Items { get; set; }
    }
public class Item 
    {
        [ForeignKey("Factor")]
        public int? FactorId { get; set; }
        public virtual Factor Factor { get; set; }
        public bool IsActive{ get; set; }
        public int ItemId { get; set; }

    }
Factors
.IncludeFilter(a => a.Items.Where(b => b.IsActive))
.FirstOrDefault(a=>a.FactorId == 1140)

這部分看起來無效:

.IncludeFilter(a => a.Items.Where(a => a.IsActive))

您使用了兩次無法編譯的“a”。

也許是錯誤的,您當前正在檢查 Factor 當前是否為IsActive而不是您的所有項目。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM