xsd.exe - How can I get automatic properties in my class generated from XSD? -


is there way automatic properties in class file that's generated xsd? using xsd2code , have tried following command.

c:\xsd2code  q2test.xsd /n contractxml /pl net35 /ap[+] /xa[+] 

it doesn't generate automatic properties. generates this:

        public string assethdrid {             {                 return this.assethdridfield;             }             set {                 this.assethdridfield = value;             }         }  private string assethdridfield; 

i want simple public string assethdrid{get;set;}

i have around 355 properties in class , wanted ask around before changing each 1 of them manually.

this answer late might useful others if looking generate properties class not contain backing fields using xsd2code. first, let's define backing field. default properties in c# .net 2.0 created using private variable , public property (where c# keyword value incoming string value):

private string _loanid; public string loanid {     get{ return _loanid; }     set{ _loanid = value; } } 

this verbose , question poster describes can bloat class. in c# 3.0, changed , properties created without backing fields:

public string loandid { get;set; } 

i used xsd2code++ v 4.2... , able set options enable property creation without backing field.
follow these steps:

  1. install xsd2code++ or xsd2code community edition
  2. right click on .xsd file
  3. in options panel, set application -> target framework net45
  4. in options panel, set settings -> propertyparams -> automatic properties true.

if have auto update set, you'll see backing properties disappear , left less verbose class. can click "generate" button see effects.

cheers!


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -