views:

18

answers:

0

I'm having a time deciding on a direction to go with a class lib I'm building.

I have a batch of industry standard XSD's, from which I'm generating .net objects. I;ve used all of XSD.exe, LinqtoXsd, xsd2code, and even OxmLibrary with varying results. But in the end, I am able to generate decent .net classes which can be serialized/deserialized to the standard.

However - The api to be called with this xml (api also part of the standard) requires that queries be strucutred as XML as well, but with some variance from the base XSD, specifically:

-presence or absense of a tag dictates that the particular fields should be "selected" or used in other manners (update, delete, add etc).

-single value types in the xsd, can be repeated in a "select" api query to indicate the equiv of a where clause for that field.

I'm likely going to use one of the code gen frameworks above to build secondary code for a query type object to complement the main data objects.

So the approaches I am considering for specifying and serializing the query objects include:

  • use "manual" serialize methods which can look at a separate query object and determine which fields to include/exclude, and can also create teh repeating tags if the query specifies multiple values.

  • change each field to inherit from a base type which is query-aware and can output the correct xml for each element.

  • use extension methods to so that class will have extra methods per field which can be called for specifying query params, and can re-use the data objects for also creating queries.

  • use anonymous types to specify a subset of fields, and geneare query xml from this

In addition to this, I also need to figure out how to hack the previously mentioned code gen fremeworks to address whichever direction I go.

I havent full thought all these through, but thought I would put this out there in case someone has done similar work and has some recommendations.