Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8409273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:51:45+00:00 2026-06-09T23:51:45+00:00

Hello and thanks in advance for the help. I have a sql table hosted

  • 0

Hello and thanks in advance for the help.
I have a sql table hosted on a server that has two columns: ID(int), server_info(xml)
The xml entries in this table look like this:

<ServerID>11</ServerID><GroupID /><ParentID>15</ParentID><ServerName>IAProd1</ServerName><User>admin</User><UID>123</UID><PWD>password</PWD><Domain>TestDomain</Domain><Location>Left</Location>

This table is represented within my Silverlight application as a ADO.Net data entity data model. I want to have a parameterized query called via the WCF service that takes an Id number and finds the children in the server table based on their parent id value which is embedded within the xml of their server_info column.
On the sql server I can do this using the following query with an xpath statment:

<!--uses xpath statement in the where clause:(server_info.value('(ServerID)[1]', 'int') = 11) --> 
    SELECT     ID, server_info
    FROM         tbl_server_xml
    WHERE     (server_info.value('(ServerID)[1]', 'int') = 11) 

Currently my query method looks something like this:

public List<tbl_server_xml> getChildServers(int parentId)
        {
            //create instance of Ado.Net entity
            xMonitorXMLTestDBEntities db = new xMonitorXMLTestDBEntities();
            var item = from entry in db.tbl_server_xml
                       where //need assistance with the where clause
                       select entry;

        }

I have not been able to figure out how to do the equivalent with just a linq query in the service method or a way to integrate xpath statements into Linq queries. Is there a way to do this or am I going about this wrong? Thank you again for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:51:47+00:00Added an answer on June 9, 2026 at 11:51 pm

    The problem is that your server_info is not a valid XML document content because it have no root element. But with a simple trick you could write your query like this

     var item = from entry in db.tbl_server_xml
                           where XDocument.Parse("<Root>" + entry.server_info + "</Root>").
                                 XPathSelectElements("//ServerID[1]").Single().Value == "11"
                           select entry;
    

    or using plain Linq to XML

    var item = from entry in db.tbl_server_xml
                               where XDocument.Parse("<Root>" + entry.server_info + "</Root>").
                                     Descendants("ServerID").First().Value == "11"
                               select entry;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello and thanks in advance for your help. I have a treeview that is
Hello all and thanks for any help in advance. I have a ruby on
Hello and thanks in advance for the communal help I always find here. I
Hello and thanks in advance for you help. I am working with a silverlight
Hello and thanks in advance for the help! I am trying to generate a
Hello i have a SQL Table which look like this: ID BEZEICHNUNG PREIS UPDATE_DATE
Hello everyone and thanks in advance. I have a problem and I have 2
Hello and thanks in advance for the assistance, I have a list of parent
Hello (and thanks in advance) I'm in a bit of a quandry, I cant
I have this kinda template text : Hello {#Name#}, Thanks for coming blah on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.