Linq Nested Inner Joins -


i want join following tables

1. b_book[1st table] -b_bid (book id)(pk) -b_name -b_categroyid (fk) 2. bi_bookinstance [2nd table] -bi_iid(instance id) -bi_bid (fk) -bi_price 3. bc_bookcategory [3rd table] -bc_categoryid (pk) -bc_categoryname 

first join b_book , bi_bookinstance join result of both bookcategory. (1st join)[b_bid equals bi_bid] (2nd nested join)[result of 1st join b_categoryid equals bc_categoryid]

edit

sql following:

select * (select * b_book b join bi_bookinstance bi on b.b_bid = bi.bi_bid) t1 join bc_bookcategoryid bc on bc.bc_categoryid = t1.b_categoryid 

what matches query in linq following (and you'll notice similarity sql). i've included examples on how rename fields returned, such price or categoryname:

var results = b in b_book join bi in bi_bookinstance on b.b_bid equals bi.bi_bid join bc in bc_bookcategory on b.b_categoryid equals bc.bc_categoryid select new { // put in whatever fields want returned here: b.b_bid, b.b_categoryid, b.b_name, bi.bi_bid, bi.bi_iid, price = bi.bi_price, bc.bc_categoryid, categoryname = bc.bc_categoryname }; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -