Introduction:
In this article,i am going to explain about how to use PLINQ to parallelize declarative data access in asp.net linq application.
Main:
What is plinq?
plinq is nothing but spliting the normal linq process into several partitions,and then using tasks to retrieve the data that
matches the criteria specified by the query for each partition in parallel. The results retrieved for each partition are
combined into a single enumerable result set when the tasks have completed. PLINQ is ideal for scenarios that involve data
sets with large numbers of elements, or if the criteria specified for matching data involve complex, expensive operations.
For achieve this,we has a enumerable method named AsParellel(),pling is especially helps us to improve linq application
performance,
See the below simple ex,create one console application,and try the below codes,you can felt the performance is quite better while using AsParallel() method,
Without AsParallel(),
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace plingdemo
{
class Program
{
static void Main(string[] args)
{
DataClasses1DataContext sqlcontext = new DataClasses1DataContext();
//normal linq
try
{
var Emps = from p in sqlcontext.Emps
join x in sqlcontext.depts
on p.Deptid equals x.dept_id
select p;
Console.WriteLine(Emps);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace plingdemo { class Program { static void Main(string[] args) { DataClasses1DataContext sqlcontext = new DataClasses1DataContext(); //normal linq try { var Emps = from p in sqlcontext.Emps join x in sqlcontext.depts on p.Deptid equals x.dept_id select p; Console.WriteLine(Emps); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace plingdemo
{
class Program
{
static void Main(string[] args)
{
DataClasses1DataContext sqlcontext = new DataClasses1DataContext();
//normal linq
try
{
var Emps = from p in sqlcontext.Emps.AsParallel()
join x in sqlcontext.depts.AsParallel()
on p.Deptid equals x.dept_id
select p;
Console.WriteLine(Emps);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace plingdemo { class Program { static void Main(string[] args) { DataClasses1DataContext sqlcontext = new DataClasses1DataContext(); //normal linq try { var Emps = from p in sqlcontext.Emps.AsParallel() join x in sqlcontext.depts.AsParallel() on p.Deptid equals x.dept_id select p; Console.WriteLine(Emps); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } |

We will do the enhancemens in pling in next article,
Conclusion:
Hope this helps,
Happy Coding.

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success.
Aw, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.
Such a well written post.. Thnkx for sharing this post!
Searching for this for some time now – i guess luck is more advanced than search engines
Great information! I’ve been looking for something like this for a while now. Thanks!
Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!
Excellent blog! I actually love how it is easy on my eyes and the facts are well written. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your rss feed which ought to do the trick! Have a nice day!
Hi buddy, your blog’s design is simple and clean and i like it. Your blog posts are superb. Please keep them coming. Greets!!!
I added your blog to bookmarks. And i’ll read your articles more often! Before this, it would be possible for the government to arrest you just based on whatever you were saying, if they didn’t like it.