indice-co/EDI.Net

X12 - Reuse data segment code (example: N1 Loop Party Identification)

Closed this issue · 1 comments

I am seeking for an advice. I created a class for each data segment such as:

[EdiSegment, EdiPath("N3")]
public class N3_PartyLocation
{
    [EdiValue(Path = "N3/0")]
    public string N3_01_AddressInformation { get; set; }
    
    [EdiValue(Path = "N3/1")]
    public string N3_02_AddressInformation { get; set; }
}

[EdiSegment, EdiPath("N4")]
public class N4_GeographicLocation
{
    [EdiValue(Path = "N4/0")]
    public string N4_01_CityName { get; set; }

    [EdiValue(Path = "N4/1")]
    public string N4_02_StateOrProvinceCode { get; set; }

    [EdiValue(Path = "N4/2")]
    public string N4_03_PostalCode { get; set; }

    [EdiValue(Path = "N4/3")]
    public string N4_04_CountryCode { get; set; }
}

I could not create the segment N1_Party_Identification because I had to create the "loop", so I included directly the N1 values.

[EdiSegment, EdiSegmentGroup("N1", SequenceEnd = "LX")]
public class N1_Loop_PartyIdentification
{
    [EdiValue(Path = "N1/0")]
    public string N1_01_EntityIdentifierCode { get; set; }

    [EdiValue(Path = "N1/1")]
    public string N1_02_Name { get; set; }
    
    public N3_PartyLocation N3_PartyLocation { get; set; }
    public N4_GeographicLocation N4_GeographicLocation { get; set; }
}

// instead of
// public class N1_Loop_PartyIdentification
// {
//    public N1_PartyIdentification N1_PartyIdentification { get; set; }
//    public N3_PartyLocation N3_PartyLocation { get; set; }
//    public N4_GeographicLocation N4_GeographicLocation { get; set; }
// }

Am I mistaken ? is there a way to have N1_PartyIdentification ?

Thank you again for your library and look forward to read you.

answering to myself, this was absolutely not annoying doing the way I described, N1 is only a loop anyway