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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:29:26+00:00 2026-06-03T12:29:26+00:00

Very basic question. How do I do modify Linq results? To expound further, I

  • 0

Very basic question. How do I do modify Linq results?

To expound further, I selected an order list from an order table in the database. I need to display the results in a gridview on a web form. First, I need to modify some of the results. For instance, the “Quote” field should be changed to blank when the “Order” field has a value. It is likely I might have to do more elaborate manipulation of the results. In the past, it was possible to loop through arrays, and modify them, but today’s programming seems to not want loops happen. At the moment the results seem to be read-only, as if I am doing something wrong by needing to modify the list.

protected void fillGridView()
{
    using (CqsDataDataContext cqsDC = new CqsDataDataContext())
    {
        var orderlist = from x in cqsDC.MasterQuoteRecs
                        where x.CustomerNumber == accountNumber && x.DateCreated > DateTime.Now.AddDays(howfar)
                        orderby x.DateCreated descending
                        select new
                        {
                            customer = x.customername,
                            order = x.OrderReserveNumber,
                            quote = x.Quote,
                            date = Convert.ToDateTime(x.DateCreated).ToShortDateString(),
                            project = x.ProjectName,
                            total = x.Cost,
                            status = x.QuoteStatus
                        };


        // I would like to loop thru list and make changes to it here

        GridView1.DataSource = orderlist;
        GridView1.DataBind();

    }
}
  • 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-03T12:29:28+00:00Added an answer on June 3, 2026 at 12:29 pm

    You end up with an IQueryable<anonymoustype> with your current query. Since they’re anonymous types they’re readonly and can’t be changed anyway.

    Your best option, especially if you intend to have more complex manipulations that can’t be done in the query by the database, is to use a class instead. You’ll also want to add a ToList() at the end of your query so you end up with a List<YourClass> and can then loop over it as you usually would and change the objects.

    So make a class that has all your properties, for example MasterQuote, and use that in your query instead:

    var query = from x in cqsDC.MasterQuoteRecs
                    where x.CustomerNumber == accountNumber && x.DateCreated > DateTime.Now.AddDays(howfar)
                    orderby x.DateCreated descending
                    select new MasterQuote
                    {
                        Customer = x.customername,
                        Order = x.OrderReserveNumber,
                        Quote = x.Quote,
                        Date = Convert.ToDateTime(x.DateCreated).ToShortDateString(),
                        Project = x.ProjectName,
                        Total = x.Cost,
                        Status = x.QuoteStatus
                    };
    
    var orderList = query.ToList();
    
    foreach (var item in orderList)
    {
        if (item.OrderReserveNumber > 0)
        {
            item.Quote = "";
        }
    }
    

    Your MasterQuote class would look something like:

    public class MasterQuote
    {
        public string Customer { get; set; }
        public int Order { get; set; }
        // and so on
    }
    

    Of course for your given example you could probably accomplish the Quote manipulation in your query as seth mentioned.

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

Sidebar

Related Questions

Very basic question - how to get one value from a generator in Python?
This is very basic question from programming point of view but as I am
Seems,that very basic question. Anyway can't get the meaning of next definition from Spring
Very basic question on adding a number rank in front of results for a
I have a very basic question. I want to use STL's list instead of
Very basic question - but I couldn't find an answer. I have got a
Very basic question- I've a xml file and I want to validate it against
A very basic question in excel. I have a column with valid and with
A very basic question.. but I always do the bad implementation of this. I
This is a very basic question, so please bear with me. Consider the following

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.