我正在尝试查询具有categoryId字段等于我的参数的类别的公司。这是我的代码:
这些是我的模特:
public class Firm
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<FirmCategory> Categories { get; set; }
}
public class Category
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<FirmCategory> Firms { get; set; }
}
public class FirmCategory
{
public int FirmId { get; set; }
public Firm Firm { get; set; }
public int CategoryId { get; set; }
public Category Category { get; set; }
}
我想做这样的事情:
var firms = _context.Firms
.Include(x => x.Categories)
.ThenInclude(x => x.Category)
.AsQueryable();
firms = firms.Where(x => x.Category.CategoryId == param.CategoryId)
我知道这行不通,但这是我想通过AsQueryable()
或ToList()
实现的目标
谢谢!
答案 0 :(得分:0)
您可以使用R
library(RMySQL)
db <- dbConnect(MySQL(), user="userName", password="passWord", dbname="mysql", host="127.0.0.1")
来实现相同的目标:
join
如果要加载公司的类别,可以:
var firms = from firm in _context.Firms
join formCategory in _context.FirmCategories on firm.Id equals formCategory.FirmId
join category in _context.Categories on formCategory.CategoryId equals category.Id
where category.Id == param.CategoryId
select firm;
答案 1 :(得分:0)
我通过使用以下命令解决了我的问题:
msbuild.exe