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

  • Home
  • SEARCH
  • 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 360459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:29:28+00:00 2026-05-12T12:29:28+00:00

How do I embed the ordinal number of element as its attribute in this

  • 0

How do I embed the ordinal number of element as its attribute in this linq query.

var AllSections = from s in xmlDoc.Descendants("section")
                      select new
                      {
                          id = s.Attribute("id").Value,
                          themeTitle = s.Element("themeTitle").Value,
                          themeText = s.Element("themeText").Value,
                          objects = (from  a in AllObjects 
                                     join b in s.Descendants("object")
                                     on  a.Attribute("accessionNumber").Value equals
                                         b.Attribute("accessionNumber").Value
                                      //select a
                                      select new
                                       {
                                        //index = insert ordinal id/index of element

                                        ObjectTitle = a.Element("ObjectTitle").Value,
                                        ObjectText = a.Element("textentry").Value,


                                        }   
                                         )


                      };
  • 1 1 Answer
  • 1 View
  • 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-05-12T12:29:28+00:00Added an answer on May 12, 2026 at 12:29 pm

    @Jon Skeet gave you the appropriate overload of Select to use, and here is it in your query:

    var AllSections = from s in xmlDoc.Descendants("section")
        select new
        {
            id = s.Attribute("id").Value,
            themeTitle = s.Element("themeTitle").Value,
            themeText = s.Element("themeText").Value,
            objects = (from a in AllObjects 
                       join b in s.Descendants("object")
                           on a.Attribute("accessionNumber").Value
                           equals b.Attribute("accessionNumber").Value
                       select a).Select((a, index) =>
                           new
                           {
                               Index = index,
                               ObjectTitle = a.Element("ObjectTitle").Value,
                               ObjectText = a.Element("textentry").Value,
                           })
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often embed a TForm descendant into another TForm descendant like this: var Form1:
Following embed code is from http://hd.se/landskrona/2010/04/09/kunglig-glans-pa-idrottsgalan/ but it doesn't work in Internet Explorer 8.
I'm trying to embed a flash file from my site, but for some reason
I embed iframe element in my HTML page: <iframe src=applet.html frameborder=0 style=width: 600px; height:
Is it possible to embed an ActiveXObject (in this case, the 3DVia Viewer) into
How can I embed an textLayout_1.0.0.595.swz into my swf file? This swz is a
I embed a text file into my Flex project and read its contents using
im trying to embed an image when sending an email with MvCMailer like this:
i'm trying to embed a swf to my as3 flex project like this: [Embed(source
I embed a MP4 movie in a page. The problem is that the video

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.