【2017-11-26】Linq表连接查询
生活随笔
收集整理的這篇文章主要介紹了
【2017-11-26】Linq表连接查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
class Program{static void Main(string[] args){//Linq創建的數據庫上下文對象dbDataClasses2DataContext db = new DataClasses2DataContext();//表連接查詢,從Student表和Score表中根據Sno相同查Sno,Sname,Cno,Degree//相當于select Student.Sno,Sname,Cno,Degree from Studet,Score where Student.Sno = Score.Sno var list = from s in db.Studentjoin c in db.Score on s.Sno equals c.Snoselect new{Sno = s.Sno,Sname = s.Sname,Cno = c.Cno,Degree = c.Degree};foreach (var l in list) {Console.WriteLine(l.Sno + " | " + l.Sname + " | " + l.Cno + " | " + l.Degree);}Console.ReadLine();}}
?
轉載于:https://www.cnblogs.com/qq609113043/p/7900235.html
總結
以上是生活随笔為你收集整理的【2017-11-26】Linq表连接查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sell02 展现层编写
- 下一篇: 遍历二叉树