With .NET 4.0, Microsoft is introducing a new Language INtegrated Query (LINQ) i.e. Parallel Language INtegrated Query (PLinq). With PLinq, we can query "in memory" collections and objects in parallel. Mind it, we can query in memory objects in parallel not the Linq to SQL. Because, parallellizing Linq to SQL means to shift the overhead to SQL Server. For that purpose we have to wait for a new version of SQL Server.
For PLinq System.Linq.ParallelEnumerable class. This class defines all the query operators which were provided with LINQ. The method to write PLinq query is just that simple. Consider a LINQ query:
This is our old friend from C# 3.0. Now, to make it a PLinq query, we will only call AsParallel() extension method on the collection after in keywork:
This method, AsParallel(), returns an object of type ParallelEnumerable. And then the where, select, groupby, thenby keywords are mapped to the extenshion methods from ParallelEnumerable. For this code, I used the old prime determination algorithm defined as:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment