EF Core Query Many to Many with filtering

前端 未结 1 349
迷失自我
迷失自我 2021-01-27 13:45

I have the following table structure:

I want to retrieve all funds for provided reportId. I did it this way:

                va         


        
相关标签:
1条回答
  • 2021-01-27 14:20

    You don't use Include with custom projections. They are alternative approaches to generating results. So just run

    var result = _context.FundsInReport
        .Where( fr => fr.ReportId == someId )
        .Select(fr => new FundsResponse()
        {
            FundId = fr.Fund.Id,
            LegalName = fr.Fund.LegalName,
            HeaderName = fr.Fund.HeaderName,
            PortfolioCurrency = fr.Fund.PortfolioCurrencyId,
            BaseCurrency = fr.Fund.BaseCurrencyId,
            FileName = fr.Fund.FileName,
            Locked = fr.Fund.Locked
        }).ToList();
    
    0 讨论(0)
提交回复
热议问题