130 likes | 308 Views
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.
E N D
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 delegate void MyDelegate(string s); MyDelegate bar = (s) => {doWork();}; invoke: bar("TEST");
Async Lambda Expression delegate void MyDelegate(string s); MyDelegate bar = (s) => {doWork();}; invoke: bar.BeginInvoke("TEST", callback, null);
Lambda Expression List<string> items = new List<string>(); vara = items.Where(item => item.StartsWith("a"));
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();
Lambda Expression List<DateTime> dates = new List<DateTime>(); List<double> ages = dates .Where(d => d.Year > 1950). .Select(d => (DateTime.Today - d).TotalDays) .ToList();
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();
LINQ (2SQL) LinqMetaDatamd = new LinqMetaData(); return md.MyTable.ToDictionary( item => item.IdMyTable, item => CSharpSub(item.MyTableField, myConstant) );
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%
PLINQ (Parallel) List<double> ages = (from d in dates.AsParallel() where d.Year > 1950 select (DateTime.Today - d).TotalDays ).ToList();
Ďakujem za pozornosť. Diskusia