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
6. 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
7. 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()
34.
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
35.
o EqualityComparer<TKey>.Default
o Equals() GetHashcode()
o
IEqualityComparer<TKey>
o
o
36.
37. 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()
…
38. from
o IEnumerable<T>
from x1 in e1
from x2 in e2
…
from * in ( e1 ) . SelectMany(
x1 => e2 , ( x1 , x2 ) => new { x1 , x2 } )
…
*
o
39.
o IEnumerable<T>
o yield return
o
o
o
o
44.
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
…
45.
46.
o IQueryable<T>
public interface IQueryable : IEnumerable
{
Type ElementType { get; }
Expression Expression { get; }
IQueryProvider Provider { get; }
}
public interface IQueryable<T> :
IEnumerable<T>, IQueryable, IEnumerable
{ }