我正在尝试将此工作 SQL 查询转换为 LINQ 查询(EF)
但在 LINQ 查询中,我无法进入类别数据表。这是我的工作 SQL 查询:
SELECT cosmetics.brand, cosmetics.product, cosmetics.size, cosmetics.price, cosmetics.sale_type, cosmetics.description, cosmetics.date, cosmetics.company_id, cosmetics.category, cosmetics.[male-female], company.company_site
FROM cosmetics INNER JOIN company ON cosmetics.company_id = company.company_id
WHERE (cosmetics.date >= GETDATE())
AND (cosmetics.[male-female] = N'female')
AND (cosmetics.category = N'cosmetics_perfumes')
ORDER BY cosmetics.brand, cosmetics.product, cosmetics.size, cosmetics.price"
这工作得很好:
var female = (from c in db.cosmetics
.Where(v => v.date > DateTime.Now)
.Where(d => d.male_female == "female")
.Include("company")
select c);
return View(female.ToList());