-
Notifications
You must be signed in to change notification settings - Fork 171
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
EdiSegment with list of EdiElement #121
Comments
If I understand this correctly you need to bind a repeating Element to a list of elements. This feature is not supported yet. As a workaround you can make multiple subclass of Information or multiple properties of [EdiSegment, EdiPath("ATR")]
public class Main
{
[EdiElement, EdiPath("ATR/0")]
Information Information { get; set; }
[EdiElement, EdiPath("ATR/1")]
Information1 Information1 { get; set; }
[EdiElement, EdiPath("ATR/2")]
Information2 Information2 { get; set; }
}
public class Information
{
[EdiValue("X(4)", Path = "ATR/0/0")]
public virtual string Code{ get; set; }
[EdiValue("X(256)", Path = "ATR/0/1")]
public virtual string Value { get; set; }
}
public class Information1 : Information
{
[EdiValue("X(4)", Path = "ATR/1/0")]
public virtual string Code{ get; set; }
[EdiValue("X(256)", Path = "ATR/1/1")]
public virtual string Value { get; set; }
}
public class Information2 : Information
{
[EdiValue("X(4)", Path = "ATR/2/0")]
public virtual string Code{ get; set; }
[EdiValue("X(256)", Path = "ATR/2/1")]
public virtual string Value { get; set; }
} Related to #105 |
This list can reach up to 99 items. I have to create Information class 99 times? |
Checkout this example https://github.com/indice-co/EDI.Net/blob/master/test/indice.Edi.Tests/Models/EdiFact_Issue121_ElementList.cs and I will be posting a beta release 1.9 soon |
Hi, Thank you works good. When you release new version? |
Just published 1.9 to nuget |
I used in project. And have problem. ATR+NEW+BRDC:J+BRDS;B+BRDT:S+BRDY:DGR [EdiSegment, EdiPath( "ATR")]
public class Main
{
[EdiPath("ATR/*")]
public List<Information> Informations { get; set; }
}
[EdiElement]
public class Information
{
[EdiValue("X(4)", Path = "*/*/0")]
public string Code { get; set; }
[EdiValue("X(4)", Path = "*/*/1")]
public string Value{ get; set; }
} I Have error. |
You have to give me a complete sample and a model. Because for this transmission the feature works as expected and binds everything.
Here is the test
|
I saw. Try use that. public class EdiFact_Issue121_ElementList
{
public Message Msg { get; set; }
[EdiMessage]
public class Message
{
[EdiCondition("NEW", CheckFor = EdiConditionCheckType.Equal, Path = "ATR/0/0")]
public List<Attribute> Attributes { get; set; }
[EdiCondition("V", CheckFor = EdiConditionCheckType.Equal, Path = "ATR/1/0")]
public List<Criteria> Attributes1 { get; set; }
}
[EdiSegment, EdiPath("ATR")]
public class Attribute
{
[EdiPath("ATR/*")]
public List<Information> Infos { get; set; }
}
[EdiElement]
public class Information
{
[EdiValue("X(4)", Path = "*/*/0")]
public string Code { get; set; }
[EdiValue("X(256)", Path = "*/*/1")]
public string Value { get; set; }
}
[EdiSegmentGroup("ATR")]
public class Criteria
{
[EdiValue("X(100)", Path = "LTS/0", Mandatory = true)]
public string Value { get; set; }
}
}
|
@dinmukhamed09 I have revisited the case and finally figured this out!! Now the deserializer can work even the last case! The following model will bind everything just fine public class EdiFact_Issue121_ElementList_Conditions
{
public Message Msg { get; set; }
[EdiMessage]
public class Message
{
[EdiCondition("NEW", CheckFor = EdiConditionCheckType.Equal, Path = "ATR/0/0")]
public List<Criteria> Attributes { get; set; }
[EdiCondition("V", CheckFor = EdiConditionCheckType.Equal, Path = "ATR/1/0")]
public List<Criteria> Attributes1 { get; set; }
}
[EdiSegment, EdiPath("ATR")]
public class Attribute
{
[EdiPath("ATR/*")]
public List<Information> Infos { get; set; }
}
[EdiElement]
public class Information
{
[EdiValue("X(4)", Path = "*/*/0")]
public string Code { get; set; }
[EdiValue("X(256)", Path = "*/*/1")]
public string Value { get; set; }
}
[EdiSegmentGroup("ATR", "LTS")]
public class Criteria : Attribute
{
public LTS LTS { get; set; }
}
[EdiSegment, EdiPath("LTS")]
public class LTS
{
[EdiValue("X(100)", Path = "LTS/0", Mandatory = true)]
public string Value { get; set; }
}
} Check the Test here
|
I will post a new version v1.9.4 |
Hi,
I have issue with Segment exist list of values.
Example:
I want get List of values like:
Attention edivalue exist n counter
1st Main:
Information[0].Code = PRIO
2nd Main:
Information[0].Code = TGIC
Information[0].Code = TGNO
Information[0].Code = TGPC
3rd Main:
Information[0].Code = ACCS
Information[0].Code = BGCL
Information[0].Code = BRDP
Information[0].Code = PRIL
The text was updated successfully, but these errors were encountered: