Linq 溫故知新

15
Linq 溫溫溫溫 Howard 2013/12/13

Transcript of Linq 溫故知新

Page 1: Linq 溫故知新

Linq 溫故知新Howard 2013/12/13

Page 2: Linq 溫故知新

先來個問題 

Page 3: Linq 溫故知新

  提示 SelectMany

Page 4: Linq 溫故知新

解答

Page 5: Linq 溫故知新

Aggregate

Page 6: Linq 溫故知新

Aggregate - Simple

This sample uses Aggregate to create a running product on the array that calculates the total product of all elements.

Page 7: Linq 溫故知新

Aggregate - Seed

This sample uses Aggregate to create a running account balance that subtracts each withdrawal from the initial balance of 100, as long as the balance never drops below 0.

Page 8: Linq 溫故知新

Deferred Execution

The following sample shows how query execution is deferred until the query is enumerated at a foreach statement.

請問輸出結果是 ?

Page 9: Linq 溫故知新

Immediate Execution

輸出結果如下,該怎麼做 ?

Page 10: Linq 溫故知新

Query Reuse

請問輸出結果是 ?

Page 11: Linq 溫故知新

cross join, inner join, outer join資料如下:

Page 12: Linq 溫故知新

cross join

怎麼做 ?

Page 13: Linq 溫故知新

inner join 怎麼做 ?

Page 14: Linq 溫故知新

outer join 怎麼做 ?

Page 15: Linq 溫故知新

References

http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b