Comments (1)
Though I managed to implement a feature while trying to achieve something like the description above, I found no easy way to support conditional values (Components
) without at least a wrapper class (Element
).
The reason behind this is essentialy that conditions are based upon other component values. This means that in order to know weather to deserialize and read a value one must search, deserialize and compare an other value (Component) residing on a different path. The `EdiReader advances its current position each time someone calls to Read from it so this is extremely inefficient in order to support any case because the reader would have to be able to seek back and forth for stuff.
Nevertheless, we have a nice working solution since release v1.0.8 where we enabled conditional Element
classes instead! These do not compromise performance.
This enables the following scenario:
Say we got this EdiFact fragment and there is 4 DTM lines near the start. These lines may or may not be in the message and represent various date times , the first number after DTM is the field code which identifies the meaning of the line, the last line specifies the time zone - so the designer of the message unfortunately "overloaded" the meaning of DTM as is so common with legacy EDI. The challenge is that these are not really a segment in the message which would allow me to use a condition attribute to pull out the data into the relevant C# property.
But you can pull the data using a Conditional & Element class attributes with the following POCOS
[EdiElement, EdiPath("DTM/0"), EdiCondition("137", Path = "DTM/0/0")]
public class CreationDate
{
[EdiValue("9(3)", Path = "DTM/0/0")]
public int Code { get; set; }
[EdiValue("X(12)", Path = "DTM/0/1", Format = "yyyyMMddHHmm")]
public DateTime Date { get; set; }
}
[EdiElement, EdiPath("DTM/0"), EdiCondition("ZZZ", Path = "DTM/0/0")]
public class CreationZone
{
[EdiValue("X(3)", Path = "DTM/0/0")]
public string Code { get; set; }
[EdiValue("9(1)", Path = "DTM/0/1")]
public int UtcOffset { get; set; }
}
public class Interchange
{
public List<Message> Messages { get; set; }
}
[EdiMessage]
public class Message
{
public CreationDate CreationDate { get; set; }
public CreationZone CreationZone { get; set; }
}
from edi.net.
Related Issues (20)
- How to omit unpopulated segment? HOT 2
- Question for path HOT 3
- X12 - automatic detection of grammar
- Set font when use EdiSerializer().Deserialize
- X12 - Segment ISA - Component element separator HOT 2
- X12 - Reuse data segment code (example: N1 Loop Party Identification) HOT 1
- X12 - N1 Loop PartyIdentification for EDI 940 HOT 1
- Parser cannot process escaped plus sign for phone number in PartyMutuallyDefined NAD record HOT 1
- Two segment groups with the same path HOT 1
- Repeating element groups within segment for X12 830 HOT 1
- Repeated elements in a segment
- Picture with implicit V9 on decimal? still adds a decimal separator HOT 4
- [Q] Error was thrown for repeated segment groups HOT 3
- EdiCondition not working to RFF+CR HOT 1
- .net8 HOT 1
- Help understanding EdiSegment Path settings HOT 3
- Some Segments does not map properly
- List wih repeating elements HOT 4
- Enum deserialization does not work
- X12 270/271 Eligibility Benefit Inquiry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edi.net.