Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity framework joins

I'm using the entity framework 4.0 and I'm having some issues with the syntax of my query. I'm trying to join 2 tables and pass a parameter to find the value at the same time.I would like find all of the products in table 2 by finding the correlating value in table 1.

Can someone help me out with syntax please?

Thanks in advance.

sample data

table 1

ID  productID   categoryID  
361 571         16  
362 572         17  
363 573         16  
364 574         19  
365 575         26

table 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);
                    }
like image 237
user686483 Avatar asked Apr 24 '26 13:04

user686483


1 Answers

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));
like image 199
Akhil Avatar answered Apr 26 '26 16:04

Akhil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!