[英]LINQ query error on Inner Join
In my ASP.NET Core app, I'm getting the following error on the following query: 在我的ASP.NET核心应用程序中,我在以下查询中收到以下错误:
Error CS0119 : 'products' is a type, which is not valid in the given context 错误CS0119 :'products'是一种类型,在给定的上下文中无效
NOTE: The above error is on the line join prod in products on.....
of the following query 注意:以上错误是在以下查询的
join prod in products on.....
的行join prod in products on.....
LINQ Query : LINQ查询 :
using System.Linq;
var innerJoinQuery =
from category in categories
join prod in products on category.ID equals prod.ID
select new { ProductName = prod.Name, Category = category.Name };
category : 类别 :
public class category
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public string categoryNumber { get; set; }
}
product : 产品 :
public class product
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public string productNumber { get; set; }
}
NOTE : This is a code first
application that has the above model classes among others. 注意 :这是一个
code first
应用程序,具有上述模型类等。
var db = new ProjNameDbContext();
var innerJoinQuery =
from category in db.categories
join prod in db.products on category.ID equals prod.CategoryID
select new { ProductName = prod.Name, Category = category.Name };
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.