|
-
Feb 2nd, 2018, 10:57 AM
#2
Re: Mapping file - looking for opinions
If you want it to be easy to parse, design a class hierarchy with the structure you want, then populate one with some fake data and use XML serialization to save it to a file. Then use that format.
If you want it to be REALLY easy to parse, use JSON.
As-is, neither of your XML formats looks like the default way XML serialization would deal with XML, but you could use attributes to get the first format. The default XML serialization scheme uses elements for each class property:
Code:
<Mappings>
<Mapping>
<OLAP>SomeTable1</OLAP>
<DataWarehouseId>Dim_SomeTable1</DataWarehouseId>
<Field>SomeTable1DimID</Field>
</Mapping>
...
If you want attributes you have to start bending the serialization framework, and eventually you have to write a parser. Once you start writing your own parsing code, there's not really a "more complex" structure. The main thing I don't like about the .NET XML serialization is it can have a tendency to want to spit out namespaces, which are a big hassle if you ever need to parse it without .NET serialization (for example, from another language).
The JSON for such a class structure implied by the XML above would look like:
Code:
{
"Mappings" : [
{
"OLAP": "SomeTable1",
"DataWarehouseId": "Dim_SomeTable1",
"Field": "SomeTable1DimId"
},
{
"OLAP": "SomeTable2",
"DataWarehouseId": "Dim_SomeTable2",
"Field": "SomeTable2DimId"
}
]
}
JSON tends to have only one way to represent any given class, which makes its parsing and manipulation much easier. Most languages have really good JSON parsers. .NET's the only one with "really good" XML parsers, and it's about like saying you had "the best tetanus shot of your life".
This answer is wrong. You should be using TableAdapter and Dictionaries instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|