1var id = 1;
2var query =
3 from post in database.Posts
4 join meta in database.Post_Metas on post.ID equals meta.Post_ID
5 where post.ID == id
6 select new { Post = post, Meta = meta };
1 var locationInfo = entities.TagTemperatures // your starting point - table in the "from" statement
2 .Join(entities.ReverseGeoFenceAddresses, // the source table of the inner join
3 tt => tt.TagTemperatureId, // Select the primary key (the first part of the "on" clause in an sql "join" statement)
4 rg => rg.TagTemperatureId, // Select the foreign key (the second part of the "on" clause)
5 (tt, rg) => new { TT = tt, RG = rg }) // selection
6 .Where(TTandRG => TTandRG.TT.TagId == tag.TagId && TTandRG.TT.SampleTime > StartDate && TTandRG.TT.SampleTime < EndDate)
7 .Select(X => new { X.TT.Latitude, X.TT.Longitude, X.TT.SampleTime, X.TT.TemperatureCelsius, X.TT.isAlert, X.TT.isYAlert, X.RG.FullAddress }).ToList(); // where statement
1IList<Student> studentList = new List<Student>() {
2 new Student() { StudentID = 1, StudentName = "John", StandardID =1 },
3 new Student() { StudentID = 2, StudentName = "Moin", StandardID =1 },
4 new Student() { StudentID = 3, StudentName = "Bill", StandardID =2 },
5 new Student() { StudentID = 4, StudentName = "Ram" , StandardID =2 },
6 new Student() { StudentID = 5, StudentName = "Ron" }
7};
8
9IList<Standard> standardList = new List<Standard>() {
10 new Standard(){ StandardID = 1, StandardName="Standard 1"},
11 new Standard(){ StandardID = 2, StandardName="Standard 2"},
12 new Standard(){ StandardID = 3, StandardName="Standard 3"}
13};
14
15var innerJoin = studentList.Join(// outer sequence
16 standardList, // inner sequence
17 student => student.StandardID, // outerKeySelector
18 standard => standard.StandardID, // innerKeySelector
19 (student, standard) => new // result selector
20 {
21 StudentName = student.StudentName,
22 StandardName = standard.StandardName
23 });
1IList<string> strList1 = new List<string>() {
2 "One",
3 "Two",
4 "Three",
5 "Four"
6};
7
8IList<string> strList2 = new List<string>() {
9 "One",
10 "Two",
11 "Five",
12 "Six"
13};
14
15var innerJoin = strList1.Join(strList2,
16 str1 => str1,
17 str2 => str2,
18 (str1, str2) => str1);
1IList<Student> studentList = new List<Student>() {
2 new Student() { StudentID = 1, StudentName = "John", Age = 13, StandardID =1 },
3 new Student() { StudentID = 2, StudentName = "Moin", Age = 21, StandardID =1 },
4 new Student() { StudentID = 3, StudentName = "Bill", Age = 18, StandardID =2 },
5 new Student() { StudentID = 4, StudentName = "Ram" , Age = 20, StandardID =2 },
6 new Student() { StudentID = 5, StudentName = "Ron" , Age = 15 }
7};
8
9IList<Standard> standardList = new List<Standard>() {
10 new Standard(){ StandardID = 1, StandardName="Standard 1"},
11 new Standard(){ StandardID = 2, StandardName="Standard 2"},
12 new Standard(){ StandardID = 3, StandardName="Standard 3"}
13};
14
15var innerJoin = from s in studentList // outer sequence
16 join st in standardList //inner sequence
17 on s.StandardID equals st.StandardID // key selector
18 select new { // result selector
19 StudentName = s.StudentName,
20 StandardName = st.StandardName
21 };