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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:14:42+00:00 2026-05-27T18:14:42+00:00

Her is an image showing a the table i have, b the grid i

  • 0

Her is an image showing a the table i have, b the grid i need to display.
opps cant post image. ill try to explain. My table have four colums.

  1. Project Number(String)
  2. ItemNumber(String)
  3. Location(String)
  4. Qty.(Real).

My grid need to look like this.

  1. ProjectNumber
  2. ItemNumber
  3. QtyMain.
  4. QtyOther.

I Need to write a linq query Grouping evry line so i will se 1 Line pr Project/ItemNumber combination summing qty into 2 differetn colums 1 showing to qty where location is main and 1 showing the qty where location is not (!=) main. Can linq do this for me, or how can thsi be done?

  • 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-27T18:14:43+00:00Added an answer on May 27, 2026 at 6:14 pm
    public class Foo
    {
        public Int32 ProjectNumber;
        public String ItemNumber;
        public String InventLocation;
        public Int32 Qty;
    }
    
    void Main()
    {
        List<Foo> foos = new List<Foo>(new[]{
            new Foo { ProjectNumber = 1, ItemNumber = "a", InventLocation = "Main", Qty = 3 },
            new Foo { ProjectNumber = 1, ItemNumber = "a", InventLocation = "Main", Qty = 3 },
            new Foo { ProjectNumber = 1, ItemNumber = "a", InventLocation = "Sub", Qty = 2 },
            new Foo { ProjectNumber = 1, ItemNumber = "a", InventLocation = "Sub", Qty = 1 },
            new Foo { ProjectNumber = 1, ItemNumber = "a", InventLocation = "Sub2", Qty = 5 }
        });
    
        var foo = from f in foos
                  group f by new { f.ProjectNumber, f.ItemNumber } into fGroup
                  select new {
                    ProjectNumber = fGroup.Key.ProjectNumber,
                    ItemNumber = fGroup.Key.ItemNumber,
                    QtyMain = fGroup.Where (g => g.InventLocation == "Main").Sum (g => g.Qty),
                    Rest = fGroup.Where (g => g.InventLocation != "Main").Sum (g => g.Qty)
                  };
        foo.Dump();
    }
    

    Resulting in:

    IEnumerable<> (1 item)  
    ProjectNumber ItemNumber QtyMain Rest 
    1             a          6       8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client who has built her entire site using html extensions. As
I need help explaining to my boss why her design is poor on a
I have a fps camera and a model of a gun that follows her,
how can I have itunes uploading an image to the directory of my app
I have to append, some text to another field when a image is clicked.
i am trying to check if user uploaded his or her avatar image and
I have wordpress page with content and image gallery. when i print_r my content,it
In the facebook graph api we have a attribute (picture) for attaching a image
I am developing a small application in android in which i have few image
I have a table which holds images of children. Now I want to read

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.