Plinq lookup parallelquery

Source: Internet
Author: User

Namespace microshaoft {using system; using system. LINQ; using system. threading. tasks; using system. threading; using system. collections. generic; using system. collections. concurrent; Class program {static void main (string [] ARGs) {var list = new list <employee> () {New Employee () {id = 100, name = "Bill Gates", Department = "Microsoft"}, new employee () {id = 2, name = "Steve Jobs", Department = "apple "}, new Employee () {id = 300, name = "Larry Page", Department = "google"}, new employee () {id = 4, name = "Sergey Brin ", department = "google"}, new employee () {id = 300, name = "Larry page2", Department = "google"}, new employee () {id = 4, name = "microshaoft", Department = "Microsoft" }}; var groups = List. tolookup <employee, string> (x => {return X. department;}); groups. asparallel (). withdegreeofparallelism (groups. count ). forall (x) => {console. writeline ("{0}, {1}", thread. currentthread. managedthreadid, X. key); var orderedgroup = x. orderbydescending <employee, int> (XX) => {return xx. ID;}); // orderedgroup. asparallel (). withdegreeofparallelism (1 ). forall // (XXX) => // {// console. writeline ("{0}, {1}", thread. currentthread. managedthreadid, xxx. name); //} //); orderedgroup. tolist (). foreach (XXX) => {console. writeline ("{0}, {1}", thread. currentthread. managedthreadid, xxx. name) ;}); console. readline ();} public class employee {public int ID {Get; set;} public string name {Get; set;} Public String Department {Get; set ;} public String gender {Get; set;} public datetime birthday {Get; Set ;}}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.