13.07.2015 Views

C# in Depth

C# in Depth

C# in Depth

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

302 CHAPTER 11 Query expressions and LINQ to Objectsfrom defect <strong>in</strong>SampleData.AllDefectsDefect: { ID=1, Project=Media player, ... }Defect: { ID=2, Project=Media player, ...}Defect: { ID=3, Project=Talk, ...}...jo<strong>in</strong> subscription <strong>in</strong>SampleData.AllSubscriptionson defect.Project equals subscription.Project<strong>in</strong>to groupedSubscriptionsfrom subscription <strong>in</strong>SampleData.AllSubscriptions(NotificationSubscription sequence){ defect=Defect: { ID=1, Project=Media player ... },groupedSubscriptions= { Media player, "media-bugs@..." ... }{ Media player, "theboss@..." ...}{ defect=Defect: { ID=2, Project=Media player ... },groupedSubscriptions= { Media player, "media-bugs@..." ... }{ Media player, "theboss@..." ...}{ defect=Defect: { ID=3, Project=Talk ... },groupedSubscriptions= { Talk, "talk-bugs@..." ... }...select new { Defect=defect,Subscriptions=groupedSubscriptions }(Result of query){ Defect=Defect: { ID=1, Project=Media player ... },Subscriptions= { Media player, "media-bugs@..." ... }{ Media player, "theboss@..." ...}{ Defect=Defect: { ID=2, Project=Media player ... },Subscriptions= { Media player, "media-bugs@..." ... }{ Media player, "theboss@..." ...}{ Defect=Defect: { ID=3, Project=Talk ... },Subscriptions= { Talk, "talk-bugs@..." ... }...Figure 11.7 Sequences <strong>in</strong>volved <strong>in</strong> the group jo<strong>in</strong> from list<strong>in</strong>g 11.13. The short arrows<strong>in</strong>dicate embedded sequences with<strong>in</strong> the result entries. In the output, some entriesconta<strong>in</strong> multiple email addresses for the same bug.List<strong>in</strong>g 11.14Count<strong>in</strong>g the number of bugs raised on each day <strong>in</strong> Augustvar dates = new DateTimeRange(SampleData.Start, SampleData.End);var query = from date <strong>in</strong> datesjo<strong>in</strong> defect <strong>in</strong> SampleData.AllDefectson date equals defect.Created.Date<strong>in</strong>to jo<strong>in</strong>edselect new { Date=date, Count=jo<strong>in</strong>ed.Count() };Licensed to Rhona Hadida

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!