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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:01:47+00:00 2026-06-05T23:01:47+00:00

Suppose I have these domain objects: DataPoint ========= public int Id {get;set;} public int

  • 0

Suppose I have these domain objects:

    DataPoint  
    =========  
    public int Id {get;set;}  
    public int TypeId  {get;set;}  
    public string Name  {get;set;}  

    Connector
    =========  
    public DataPoint DataPoint1 {get;set;}  
    public int DataPoint1Id {get;set;}
    public DataPoint DataPoint2 {get;set;}   
    public int DataPoint2Id {get;set;}
    public string Name {get;set;} 
    public int TypeId {get;set;}  

I have a List<Connector>:

    List<Connector> _Connectors = new List<Connector>()
    {
     new Connector(){Name = "a", DataPoint1Id = 1, DataPoint2Id = 2},...
     new Connector(){Name = "b", DataPoint1Id = 1, DataPoint2Id = 2},... 
     new Connector(){Name = "c", DataPoint1Id = 1, DataPoint2Id = 2},...  
     new Connector(){Name = "d", DataPoint1Id = 2, DataPoint2Id = 1},...
     new Connector(){Name = "e", DataPoint1Id = 2, DataPoint2Id = 1}...
    }

I’m doing grouping with LINQ as follows:

    var groups = (from C in _Connectors
                  group C by new { C.DataPoint1Id, C.DataPoint2Id }
                  into cGroup                                             
                  select new {cGroup.Key.DataPoint1Id, cGroup.Key.DataPoint2Id,      
    cGroup.ToList(), cGroup.Count()});

var groups holds:

    DataPoint1Id = 1, DataPoint2Id = 2, list of connectors -"a","b","c", count = 3
    DataPoint1Id = 2, DataPoint2Id = 1, list of connectors - "d","e", count = 2  

I would like to merge these 2 objects into 1 :

    DataPoint1Id = 1, DataPoint2Id = 2, list of connectors - "a","b","c","d","e", count = 5

How can I achieve that?

  • 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-05T23:01:49+00:00Added an answer on June 5, 2026 at 11:01 pm

    How about

    var groups =
        from C in _Connectors
        group C by new
            {
                Min = (int)Math.Min(C.DataPoint1Id, C.DataPoint2Id),
                Max = (int)Math.Max(C.DataPoint1Id, C.DataPoint2Id)
            }
        into cGroup
        select new
            {
                DataPoint1Id = cGroup.Key.Min,
                DataPoint2Id = cGroup.Key.Max,
                Connectors = cGroup.ToList(),
                Count = cGroup.Count()
            };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have these tables create table bug ( id int primary key, name
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
Suppose I have an IEnumerable<int> and I want these to be converted into their
suppose I have MyClass domain class: class MyClass { String prop1 String prop2 String
Suppose i have the following class. public class Location { public Id { get;
Suppose I have several services represented by classes ServiceA, ServiceB, ServiceC etc. These services
Suppose that I have n points (x,y1),(x2,y2),.....(xn,yn) my aim is to connect these points
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Suppose I have a string that contains Ü. How would I find all those

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.