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 7075473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:54+00:00 2026-05-28T06:10:54+00:00

I have the following class that is used to hold data for reporting only.

  • 0

I have the following class that is used to hold data for reporting only.

public class AdminDetail
{
    public int    Row { get; set; }   // This row needs a unique number 
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string Title { get; set; }
    public string Status { get; set; }
    public string Type { get; set; }
    public string Level { get; set; }
    public string Order { get; set; }
}

Populated with the following select on the _table collection.

 details = from t in _table
                      select new AdminDetail
                      {
                          PartitionKey = t.PartitionKey,
                          RowKey = t.RowKey,
                          Title = t.Title,
                          Status = t.Status,
                          Type = t.Type,
                          Level = t.Level,
                          Order = t.Order
                      };

            detailsList = details.OrderBy(item => item.Order).ThenBy(item => item.Title).ToList();

After the rows are sorted with the last statement I would like to give to put a value into the RowID
that corresponds to the row. So if I had three instances returned I would like them to have the RowID
1,2 and 3.

Is there a way that I can do this with LINQ?

  • 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-05-28T06:10:55+00:00Added an answer on May 28, 2026 at 6:10 am

    You could do it using the Select overload which provides an index, but you’d probably want to do the projection to AdminDetail after the ordering:

    var ordered = from item in _table
                  orderby item.Order, item.Title
                  select item;
    
    var details = ordered.Select((t, index) => new AdminDetail
                                 {
                                     PartitionKey = t.PartitionKey,
                                     RowKey = t.RowKey,
                                     Title = t.Title,
                                     Status = t.Status,
                                     Type = t.Type,
                                     Level = t.Level,
                                     Order = t.Order,
                                     Row = index + 1
                                 })
                          .ToList();
    

    Aside from anything else, this way if _table is a LINQ to SQL table (or something similar) the ordering can be performed in the database rather than in LINQ to Objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that looks like the following: public class MyClass { private
We have a class a class that looks something like the following: public class
So I have a class that has the following member variables. I have get
Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string
Lets say that I have the following code: public class Shelter<A extends Animal, B
I have a templated container class that internally stores data in a following, static,
I have the following class that's used by my MVC3 application. I would like
I have the following class: public class NoteLink { public IList<NoteLinkDetail> NoteLinkDetails { get
Good morning SO, I have a class that contains the following static array: public
I have the following members defined in a class that I'm trying to deserialise:

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.