简体   繁体   中英

How to use ADO.Net Entity Data Model with two tables?

I have two tables: Student (StuID, Name, Sex, MajorID, ...) and Major (MajorID, MajorName, ...). I would like to get result: StuID, Name, MajorName. How to retrieve this record using ADO.Net Entity Data Model?

I think that you are asking for C# LINQ query, if you are not, please ignore my anwser.

var result = from s in Student 
             join m in Major on s.MajorID equal m.MajorID
             select new {s.StuID, s.Name, m.MajorName}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM