Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. How to? Excluding referenced types while generating DTOs [modified]

How to? Excluding referenced types while generating DTOs [modified]

Scheduled Pinned Locked Moved WCF and WF
helpquestioncsharpwcftutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 2 Offline
    2 Offline
    2005732
    wrote on last edited by
    #1

    I've googled this to the point of absolute frustration without success, but it's what I would consider a noob question I'm hoping someone can help me with. There has been a lot of close-but-not-quite conversation on the interwebs about my issue so I'm going to be as explicit as I can (aka verbose ... sorry). My goal is to use svcutil to generate my datacontracts which are also my DTO's for my WCF service. Everything works great until i have a datacontract that contains another datacontract ... and it does work ... except I have to manually go into the referencing generated class and remove the duplicated definition ... EVERYTIME I regenerate. I thought the svcutil /excludetype (/et) option would do this but I can't get it to work. Here is an illustration: I have an .xsd file that looks like this: (I'm leaving out the headers removing all but a single property to keep it simple. In reality there is obviously a lot more to this than a phone number.)

    <xs:complexType name="ContactDTO">
    xs:sequence
    <xs:element minOccurs="0" maxOccurs="1" name="PhoneNumber" type="xs:string" />
    xs:sequence
    xs:complexType

    I run it through svcutil and it generates my datacontract perfectly and I get a ContactDTO.vb class. But then I have another xsd that references the first like so: (again.. greatly simplified to not waste your time)

    <xs:include schemaLocation="ContactDTO.xsd"/>

    <xs:complexType name="CustomerDTO">
    xs:sequence
    <xs:element minOccurs="0" maxOccurs="1" name="CustomerName" type="xs:string" />
    <xs:element minOccurs="0" maxOccurs="1" name="Contact" type="ContactDTO" />
    xs:sequence
    xs:complexType

    After a bunch of trail and variation I've landed on using the following command line to generate the classes:

    svcutil /dconly ./CustomerDTO.xsd /n:http://mynamespacegoeshere.ccc/Schemas, /out:./Classes/CustomerDTO.vb /language:VB ./ContactDTO.xsd /et:ContactDTO.xsd

    And like i said, it does work ... but I get two classes, the CustomerDTO.vb class which I want and ANOTHER copy of the ContactDTO.vb class that has already been generated previously and i have to go into my generated classes and hand edit the duplicates out. Now I could just not generate the first class however the point is resuse ... so I have several OTHER classes that reference ContactDTO and I have to edit out every instance of the duplicate generated cod

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups