Data Contracts -- can I import classes?

Sep 11, 2009 at 10:40 PM

I'm really strugging with the limitations of the data contracts :( . I have a whole object model from another application that I'd like to re-use in my data contracts. Is this possible, or easy to do? Also, why can't data contracts contain ints and bools?


Sep 14, 2009 at 11:04 AM

The way you can reuse your types in DCs is by getting the WSDL from your object model or your schema types and reference them from your Service Contract model using the XsdMessage elements where you can add references to your types. In this scenario you will be using a "Contract First" apporach and therefore you will not be using the DataContract models because this will be replaced by your shema types. In case you don;t have a schema type and only have an object model, you can get it by running the Xsd.exe tool or thw svcutil tool to get the schema types from your CLR types. If you already have a service along with the WSDL you may use the WSDL Importer to create your Service Contract along with the schema types.