LINQ queries the corresponding sub-level data based on the input data set

Source: Internet
Author: User

Frequently Used in the work, LINQ queries corresponding sub-level data based on the input data set, organizes and shares, and hopes everyone can use it. In the code, doublesarray is the ID data set of the parent node, query all sub-level data based on the ID data set.

// Obtain the cached data object OBJ = caching. getcache (cachekey + umodel. roleid); If (OBJ! = NULL) // determines whether the cached data is null {sysfunlist = (Dataset) OBJ;} else {string strsql = "select * From view_sysrolelist where loginid = '" + umodel. loginid + "'order by [custom_displayorder]"; sysfunlist = sqlhelper. query (sqlhelper. localsqlserver, strsql. tostring (); caching. setcache (cachekey + umodel. roleid, sysfunlist);} // obtain the data of all parent nodes in the dataset var query = (from T in sysfunlist. tables [0]. asenumerable () where T. field <int> ("custom_parentnodeid") = 0 select T); If (query. count ()> 0) {// LINQ obtains the ID var doublesarray = query for all parent nodes in the data. select (one => one. field <int> ("custom_nodeid"); If (doublesarray. count ()> 0) {// LINQ obtains the corresponding next-level data var foos = from TQ in sysfunlist Based on the ID data. tables [0]. asenumerable () Where doublesarray. contains (TQ. field <int> ("custom_parentnodeid") orderby TQ. field <int> ("custom_displayorder") descending select TQ; // converts it to datatable boundtable = Foos. copytodatatable <datarow> (); repeatermeau. datasource = boundtable; repeatermeau. databind ();}}


LINQ queries the corresponding sub-level data based on the input data 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.