Your SlideShare is downloading. ×
0
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
LINQ Internals - STLDODN
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

LINQ Internals - STLDODN

1,790

Published on

Though Language INtegrated Query provides a revolutionary way to write code in C# 3.0 and Visual Basic 9, it is powerless without several enabling language features and libraries. This session will …

Though Language INtegrated Query provides a revolutionary way to write code in C# 3.0 and Visual Basic 9, it is powerless without several enabling language features and libraries. This session will explore the technologies that make LINQ possible and show how you can use the same techniques to make LINQ work for you.

Presented Aug. 28 & 29, 2009 at St. Louis Day of .NET

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,790
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
48
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1.      
  • 2.       
  • 3.   o o  o o
  • 4.  o   o
  • 5. var entry = new { Dim entry = New With { _ Title = "Dear Diary", .Title = "Dear Diary", _ DateTime.Now DateTime.Now _ }; } Console.WriteLine("{0:d}: {1}", Console.WriteLine("{0:d}: {1}", _ entry.Now, entry.Title); entry.Now, entry.Title) var Dim
  • 6.  static Module  using Imports  Imports System.Runtime.CompilerServices Module StringExtensions <Extension()> _ Public Sub Print(ByVal aString As String) Console.WriteLine(aString) End Sub End Module Dim hello = "Hello from StringExtensions" hello.Print()
  • 7.  this static void ForEach<T>(this IEnumerable<T> source, Action<T> action) { foreach (T o in source) action(o); }  delegate void Action(); delegate void Action<T>(T arg); delegate void Action<T1, T2>(T1 arg1, T2 arg2); delegate TResult Func<TResult>(); delegate TResult Func<T, TResult>(T arg); delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);
  • 8.  delegate string MyDelegate(int i); static string MyMethod(int i) { … } MyDelegate del1 = new MyDelegate(MyMethod); // C# 1.0 MyDelegate del2 = delegate(int i) { … }; // C# 2.0 MyDelegate del3 = MyMethod; // C# 2.0 MyDelegate del4 = (int i) => { … }; // C# 3.0 Func<int, string> del5 = i => { … }; // C# 3.0  Dim del4 As MyDelegate = Function(i As Integer) …
  • 9.    Expression<Func<int, int>> inc = (a => a + 1);  ParameterExpression CS$a; Expression<Func<int, int>> inc = Expression.Lambda<Func<int, int>>( Expression.Add( CS$a = Expression.Parameter(typeof(int), "a"), Expression.Constant(1, typeof(int))), new ParameterExpression[] { CS$a });
  • 10.  var names = from s in Students where s.Age % 2 == 0 orderby s.Name descending select s.Name;  IEnumerable<string> names = Students.Where(s => s.Age % 2 == 0) .OrderByDescending(s => s.Name) .Select(s => s.Name);
  • 11.  o o  o  o
  • 12.  o   o  o   o   o o  o   o   o  o 
  • 13.              
  • 14.  from x1 in e1 join x2 in e2 on k1 equals k2 …  from * in ( e1 ) . Join( e2 , x1 => k1 , x2 => k2 , (x1 , x2) => new { x1 , x2 }) …  o this o o o o
  • 15.  o EqualityComparer<TKey>.Default  o Equals() GetHashcode() o  IEqualityComparer<TKey> o o
  • 16.  into o o Func<TOuter, TInner, TResult> resultSelector  into o o o Func<TOuter, IEnumerable<TInner>, TResult> resultSelector  o DefaultIfEmpty() from x1 in e1 join x2 in e2 on k1 equals k2 into j from xj in j . DefaultIfEmpty() …
  • 17.  from o IEnumerable<T>  from x1 in e1 from x2 in e2 …  from * in ( e1 ) . SelectMany( x1 => e2 , ( x1 , x2 ) => new { x1 , x2 } ) …  * o
  • 18.   o IEnumerable<T>  o yield return  o o o o
  • 19.  o o  o • foreach o  o  o
  • 20.  o o IEnumerable<>  o o EnumerableRowCollection<DataRow> AsEnumerable(this DataTable source) o EnumerableRowCollectionExtensions  o Cast<T>() OfType<T>() o foreach from MyType obj in MyArrayList …
  • 21.   o IQueryable<T> public interface IQueryable : IEnumerable { Type ElementType { get; } Expression Expression { get; } IQueryProvider Provider { get; } } public interface IQueryable<T> : IEnumerable<T>, IQueryable, IEnumerable { }
  • 22.  public interface IQueryProvider { IQueryable CreateQuery(Expression expression); IQueryable<TElement> CreateQuery<TElement>(Expression expression); object Execute(Expression expression); TResult Execute<TResult>(Expression expression); }
  • 23. public static TSource First<TSource>( this IQueryable<TSource> source) { return source.Provider.Execute<TSource>( Expression.Call(null, ((MethodInfo) MethodBase.GetCurrentMethod()) .MakeGenericMethod(new Type[] { typeof(TSource) }), new Expression[] { source.Expression } ) ); }
  • 24.  IEnumerable IQueryable   o o  o o
  • 25.   o  o o o

×