实体框架加入

use*_*483 3 join skip entity-framework-4 take

我正在使用实体框架4.0,我的查询语法有些问题.我正在尝试连接2个表并传递一个参数来同时查找该值.我想通过查找表1中的相关值来查找表2中的所有产品.

有人可以帮我解决语法问题吗?

提前致谢.

样本数据

表格1

ID  productID   categoryID  
361 571         16  
362 572         17  
363 573         16  
364 574         19  
365 575         26
Run Code Online (Sandbox Code Playgroud)

表2

productID   productCode

571     sku

572     sku

573     sku

574     sku

575     sku 




var q = from i in context.table1
                            from it in context.table2
                            join <not sure> 
                            where i.categoryID == it.categoryID and < parameter >
                          select e).Skip(value).Take(value));

                    foreach (var g in q)
                    {
                        Response.Write(g.productID);
                    }
Run Code Online (Sandbox Code Playgroud)

Akh*_*hil 5

var q = from i in context.table1
        join it in context.table2 on i.productID equals it.productID
        where i.categoryID == it.categoryID and it.productCode = xyz
      select i).Skip(value).Take(value));
Run Code Online (Sandbox Code Playgroud)