Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q] Dealing with optional segment properties and segments #228

Open
tcsyring opened this issue Apr 26, 2022 · 0 comments
Open

[Q] Dealing with optional segment properties and segments #228

tcsyring opened this issue Apr 26, 2022 · 0 comments

Comments

@tcsyring
Copy link

I am wondering what is the best way for dealing with optional segments and segment properties, so that I dont end up with a complex object structure that has a large amount of null values?

For example, given an NM1 X12 EDI Segment, which has a total of 12 possible fields, however only the first two or mandatory. Making those optional fields nullable (as shown in the below codeblock) in my model seems to have no effect.


    [EdiSegment, EdiPath("NM1")]
    public class NM1
    {
        [EdiValue("X(3)", Path = "NM1/0", Description = "NM101 - Entity Identifier Code")]
        public string EntityIdentifierCode { get; set; }

        [EdiValue("X(1)", Path = "NM1/1", Description = "NM102 - Entity Type Qualifier")]
        public string EntityTypeQualifier { get; set; }

        [EdiValue("X(60)", Path = "NM1/2", Description = "NM103 - Name Last or Organization Name")]
        public string? NameLastOrOrganizationName { get; set; }

        [EdiValue("X(35)", Path = "NM1/3", Description = "NM104 - Name First")]
        public string? NameFirst { get; set; }
        ...

This issue also presents itself when using the segments to create complex EdiSegmentGroup's.

[EdiSegmentGroup("NM1", new[] { "PER", "N3", "N4", "DMG", "EC", "ICM", "AMT", "HLH", "HI", "LUI" })]
    public class Loop2100 : NM1
    {
        public PER PER { get; set; }
        public N3? N3 { get; set; }
        ...

The result is many optional properties with many null values. Is there any way to avoid this?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant