TABLE 1:
TID:
TNAME:
T开发者_开发知识库DESC:
TABLE 2::
AID:
ANAME:
ADESC:
TABLE 3
TID:
AID:
How to write a Linq query to get list of table2 by passing TNAME in TABLE 1.:
Please help!
Assuming you have the correct FK relationships in your database you just type
from t2 in context.table2s
where t2.table3.table1.TNAME == "SomeName"
select t2
Edit
If you don't have foreigns in your database you can either "cheat" by drawing relations in the DBML designer or you need to resort to explicit joining
from t2 in context.table1s
join t3 in context.table3s
on t2.AID equals t3.AID
join t1 in context.table1s
on t3.TID equals t1.TID
where t1.TNAME == "SomeName"
select t2
you need to use join. something like this
from t1 in db.Table1
join t2 in db.Table2 on t1.field equals t2.field
select new { t1.field2, t2.field3}
plz, chek LinqJoin
精彩评论