LINQ查询帮助..两个选择查询.. [英] LINQ Query Help.. Two selects query..
本文介绍了LINQ查询帮助..两个选择查询..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从table1中选择年份
sid =(从table2中选择sid,其中roll = 1)
如何写上面的查询在LINQ2SQL中...
我是lniq对sql的新手..
谢谢提前..
亲爱的..
Select year from table1 where
sid = (select sid from table2 where roll=1)
how Can I write above query in LINQ2SQL ...
I''m new to lniq to sql..
Thanks in Advance..
Honey..
推荐答案
试试如下所示。
Hi,
try like below.
var result = from tb1 in context.table1s
join tb2 as
(from val in context.table2s where val.Field<int>("roll") == 1 select val)
on tb1.Field<int>("sid") equals tb2.Field<int>("sid") select tb1;
请参阅以下文章,了解有关LINQ to SQL的更多信息。
初学者的LINQ to SQL指南 [ ^ ]
LINQ to SQL简介 [ ^ ]
希望它有所帮助。
refer below articles for more on LINQ to SQL.
Beginner''s Guide to LINQ to SQL[^]
Introduction to LINQ to SQL[^]
hope it helps.
这篇关于LINQ查询帮助..两个选择查询..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文