Skip to content
This repository was archived by the owner on Sep 11, 2019. It is now read-only.

Commit 8cf060f

Browse files
committed
LINQ p2: add more additional resources; fix typos
Add links to edulinq project and linq samples Change sum to more revolutionary result Fix typos
1 parent 6fd5feb commit 8cf060f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

slides/11 LINQ pt2/index.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Object-Relational Mapping (ORM) which allows you:
130130

131131
- Work with data-store in object-oriented way
132132
- Query any supported data source
133-
- Potantially change data source
133+
- Potentially change data source
134134
- Has own change tracking system which can be extended
135135
- Business specifications can be reused throughout your project
136136
- Currently prefered data access in wich Microsoft invests the most
@@ -453,8 +453,8 @@ A group join produces a sequence of object arrays based on properties equivalenc
453453
```cs
454454

455455
from s in Students
456-
join c in Courses on s.StudentID equals a.StudentID into t
457-
select { StudentName = s.Name, Courses = t }
456+
join c in Courses on s.StudentID equals s.StudentID into t
457+
select new { StudentName = s.Name, Courses = t }
458458

459459
```
460460

@@ -474,7 +474,7 @@ If there are no columns matching in the right table, it returns NULL values.
474474
from s in Students
475475
join a in Addresses on s.AddressID equals a.AddressID into t
476476
from st in t.DefaultIfEmpty()
477-
select { AddressID = (int?)st.AddressID, st.City, StudentName = s.Name }
477+
select new { AddressID = (int?)st.AddressID, st.City, StudentName = s.Name }
478478

479479
```
480480

@@ -490,7 +490,7 @@ Cross join returns records or rows that are multiplication of record number from
490490

491491
from s in Students
492492
from a in Addresses
493-
select { a.City, s.Name }
493+
select new { a.City, s.Name }
494494

495495
```
496496

@@ -527,8 +527,8 @@ var count = nums.Count(); // 9
527527

528528
```cs
529529

530-
int[] nums = {500,100,50,20,10,5,2,1,1000};
531-
var count = nums.Sum(); // 1688
530+
int[] nums = {300,100,50,20,10,5,2,1,1000};
531+
var count = nums.Sum(); // 1488
532532
533533
```
534534

@@ -574,8 +574,8 @@ Performs custom aggregation:
574574

575575
```cs
576576

577-
int[] nums = {500,100,50,20,10,5,2,1,1000};
578-
var sum = nums.Aggregate(0, (total, n) => total + n); // 1688
577+
int[] nums = {300,100,50,20,10,5,2,1,1000};
578+
var sum = nums.Aggregate(0, (total, n) => total + n); // 1488
579579
580580
```
581581

@@ -644,7 +644,7 @@ IEnumerable<string> strings = values.OfType<string>();
644644
object[] values = new object[] {"1", "2", "3", "AAA", 5};
645645
IEnumerable<string> strings = values.Cast<string>();
646646
// an exception will be thrown
647-
//because the last element is not string
647+
// because the last element is not string
648648
649649
```
650650

@@ -670,4 +670,6 @@ var flatten = values.SelectMany(s => s);
670670

671671
Additional resources:
672672

673-
- https://weblogs.asp.net/dixin/linq-via-csharp
673+
- https://weblogs.asp.net/dixin/linq-via-csharp
674+
- https://codeblog.jonskeet.uk/category/edulinq
675+
- http://linqsamples.com

0 commit comments

Comments
 (0)