C# LINQ separate row into two rows based on List<String> property

C# LINQ separate row into two rows based on List<String> property

I have a list of&nbsp;<code>IPInfo</code>&nbsp;objects already filtered in some way. My problem is to separate records based on last&nbsp;<code>List&lt;String&gt;</code>&nbsp;property:

I have a list of IPInfo objects already filtered in some way. My problem is to separate records based on last List<String> property:

class IPInfo
{
    public String TRADE_DATE; 
    public String CUSTOMER_NAME;
    public List<String> ORIGINAL_IP;
    public List<String> LOGON_IP = new List<String>();
}

List<IPInfo> fields when exported to .xls file looks like this: 


I need each Logon IP record to be in a separate row, but Original IP to remain combined. On a picture, for CITI I need:

----------------------------------------------
10.55.13.104     |   128.110.34.102
128.110.34.102   |
----------------------------------------------
10.55.13.104     |   10.55.13.104
128.110.34.102   |

Any help?

EDIT: this query was applied before to combine duplicated Logon IPs. But, as I told, I need Logon IPs separated

    private static List<IPInfo> selectFields(ref List<IPInfo> fields)
    {
        var distinct =
            fields
                .GroupBy(x => new { x.TRADE_DATE, x.CUSTOMER_NAME })
                .Select(y => new IPInfo()
                {
                    TRADE_DATE = y.Key.TRADE_DATE,
                    CUSTOMER_NAME = y.Key.CUSTOMER_NAME,
                    ORIGINAL_IP = y.SelectMany(x => x.ORIGINAL_IP).Distinct().ToList(),
                    LOGON_IP = y.SelectMany(x => x.LOGON_IP).Distinct().ToList()
                })
                .ToList();

    return distinct;
}


c-sharp linq

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Is Using LINQ in C# Bad for Performance?

LINQ (Language INtegrated Query) is a set of features in C# for concise and declarative code. I use it pretty much wherever I can, but sometimes I wonder and people ask: is this a performance trap? It would be painful to have to replace many usages of LINQ with other constructs in addition to time spent finding that to be an actual bottleneck. Let’s do a basic benchmark to see what using LINQ might cost us compared to more traditional constructs such as for and foreach loops, and see if this worry is valid.

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five. 아시죠? C는 C++.C# 줄인말이 아니라는거?

Dicey Issues in C/C++

C/C++ problems. If you are familiar with C/C++then you must have come across some unusual things and if you haven’t, then you are about to. The below codes are checked twice before adding, so feel free to share this article with your friends.

Learn how to perform CRUD operations using C Sharp

QuickStart: CRUD Operations in C Sharp. Learn how to perform CRUD operations using C Sharp for MongoDB databases.

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.