Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Using IsDescendantOf with LINQ

Using IsDescendantOf with LINQ

Scheduled Pinned Locked Moved LINQ
csharpdatabasesql-serverlinq
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mycroft Holmes
    wrote on last edited by
    #1

    I am attempting to use Linq to filter a datatable to get the descendants of a node based on SQLHierarchyID. This compiles but does not return any results, the same query in TSQL returns the correct records.

    //filter the table using linq.
    EnumerableRowCollection query = from TNodes in oTable.AsEnumerable()
    where TNodes.Field("NodeKey").IsDescendantOf(hID).Equals(true)
    select TNodes;

    Any suggestions welcome.

    J 1 Reply Last reply
    0
    • M Mycroft Holmes

      I am attempting to use Linq to filter a datatable to get the descendants of a node based on SQLHierarchyID. This compiles but does not return any results, the same query in TSQL returns the correct records.

      //filter the table using linq.
      EnumerableRowCollection query = from TNodes in oTable.AsEnumerable()
      where TNodes.Field("NodeKey").IsDescendantOf(hID).Equals(true)
      select TNodes;

      Any suggestions welcome.

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      Can I see a sample of your xml, im sure this one should be easy enough. Edit: I mean the xml generated by your dataset, so I could test a solution.

      Mycroft Holmes wrote:

      .Equals(true)

      That bit should be superfluous.

      M 1 Reply Last reply
      0
      • J J4amieC

        Can I see a sample of your xml, im sure this one should be easy enough. Edit: I mean the xml generated by your dataset, so I could test a solution.

        Mycroft Holmes wrote:

        .Equals(true)

        That bit should be superfluous.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        J4amieC wrote:

        Can I see a sample of your xml, im sure this one should be easy enough.

        Nope, it's 6pm and I'm sitting here (at home) with a nice glass of white and that bloody thing has been left in the office. VS grumbled until I put the .Equals on the end. The only relevant thing should be that the NodeKey is a SQLHierarchyID I would think. I eventually chucked linq and went back to a stored proc to do the job - I'm seriously not happy with linq as it continually dissapoints.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups