EDI.Net
EDI.Net copied to clipboard
Fail to group several segments in a hierarchy of member classes when de-serialize
Hi.
Do I miss proper usage of EdiSegmentGroup attribute?
Here is excerpt of 943 Warehouse Stock Transfer Shipment Advice, where W04 is “Item detail total” and N9 is a reference to this detail. My intention is to encapsulate in a member class of Line the identification (N9) and item details (W04) in of Purchase Order.
Problem is that the ItemDetailTotal type in my code is de-serialized as a null and segment W04 elements are not assigned to properties of ItemDetailTotal.
I only can get it working when put all segments for W04 and N9 directly under Line member class, that is the closest I can get.
I thought of keeping them in individual member classes with EdiSegment attributes as below.
ST*943*000001234~ W06*R*15107*20210329********PO~ N1*WH**12*1111~ N3*Abcd~ W27*M*KTML~ W04*1000*EA**VN*5900*LT~ N9*LI*10~ W04*5000*EA**VN*8530*LT~ N9*LI*20~ W03*0~ SE*12*000007242~
[EdiMessage]
public class StockTransferShipmentAdviceMessage
{
public List<Line> Lines { get; set; }
/// <summary>
/// W03
/// </summary>
public TotalShipmentInformation Totals { get; set; }
}
[EdiSegment, EdiSegmentGroup("W04", SequenceEnd = "W03")]
public class Line
{
/// <summary>
/// W04
/// </summary>
public ItemDetailTotal ItemDetail { get; set; }
/// <summary>
/// N9
/// </summary>
public ReferenceIdentification ReferenceNumber { get; set; }
}
[EdiSegment, EdiPath("W04")]
public class ItemDetailTotal
{
[EdiValue("9(9)", Path = "*/0", Description = "Number of units")]
public string NumberOfUnitsShipped { get; set; }
[EdiValue(Path = "*/1", Description = "Measurements")]
public string UnitsOfMeasurement { get; set; }
[EdiValue("X(20)", Path = "*/2")]
public string UpcCaseCode { get; set; }
}
/// <summary>
/// N9
/// </summary>
[EdiSegment, EdiPath("N9")]
public class ReferenceIdentification
{
[EdiValue(Path = "*/0", Description = "N901 - ‘LI’ (Line Item Identifier)")]
public string ReferenceIdentificationQualifier { get; set; }
[EdiValue(Path = "*/1", Description = "N902 - LI – Customer Line Reference")]
public string Value { get; set; }
[EdiValue(Path = "*/2", Description = "N903 - Reference Description")]
public string Description { get; set; }
}
@maussi sorry for the late reply. Your question is very frequently asked you can check previous replies on the subject "loop" or "group" on the issues tab. Also check these answers for reference.
- https://github.com/indice-co/EDI.Net/issues/171#issuecomment-704745116
- https://github.com/indice-co/EDI.Net/issues/176#issuecomment-720631786