C# LINQ separate row into two rows based on List<String> 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

1 Likes2.90 GEEK