1 / 13

LINQ

LINQ. (Language Integrated Query). Ľubomír Teťák. Function. void doWork () { // } invoke: doWork ();. Anonymous Function. delegate void MyDelegate(string s); MyDelegate bar = delegate (string s) { doWork (); }; invoke: bar ("TEST");. Lambda Expression.

peri
Download Presentation

LINQ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LINQ (Language Integrated Query) Ľubomír Teťák

  2. Function void doWork() { // } invoke: doWork();

  3. Anonymous Function delegate void MyDelegate(string s); MyDelegate bar = delegate(string s) {doWork();}; invoke: bar("TEST");

  4. Lambda Expression delegate void MyDelegate(string s); MyDelegate bar = (s) => {doWork();}; invoke: bar("TEST");

  5. Async Lambda Expression delegate void MyDelegate(string s); MyDelegate bar = (s) => {doWork();}; invoke: bar.BeginInvoke("TEST", callback, null);

  6. Lambda Expression List<string> items = new List<string>(); vara = items.Where(item => item.StartsWith("a"));

  7. Lambda Expression List<string> items = new List<string>(); var a = items.Where(item => item.StartsWith("a")); varb = a.OrderBy(item => item.Length); List<string> c = b.ToList();

  8. Lambda Expression List<DateTime> dates = new List<DateTime>(); List<double> ages = dates .Where(d => d.Year > 1950). .Select(d => (DateTime.Today - d).TotalDays) .ToList();

  9. LINQ (2objects) List<DateTime> dates = new List<DateTime>(); List<double> ages = (from d in dates where d.Year > 1950 select (DateTime.Today - d).TotalDays ).ToList();

  10. LINQ (2SQL) LinqMetaDatamd = new LinqMetaData(); return md.MyTable.ToDictionary( item => item.IdMyTable, item => CSharpSub(item.MyTableField, myConstant) );

  11. PLINQ (Parallel) dates.Select(d => longCalc(d)); • (dates.Count: 1000; longCalcrunning time: 100 ms) • Running time: 100 593 ms dates.AsParallel().Select(d => longCalc(d)); • Running time: 12 625 ms = 12.6%

  12. PLINQ (Parallel) List<double> ages = (from d in dates.AsParallel() where d.Year > 1950 select (DateTime.Today - d).TotalDays ).ToList();

  13. Ďakujem za pozornosť. Diskusia

More Related