Skip to content
Moh.Hassan edited this page Feb 24, 2019 · 2 revisions

How to

Generating [Key] Attribute for the properties

e.g.

[Key]
public int CategoryID {get;set;} 

Use the options: -k

or -a key

Note: Only [Key] is generated if the property is defined in the Xml Metadata as key.


Generating [Required] Attribute for the properties

e.g.

[Required]
public int CategoryID {get;set;} 

Use the option: -q

Or the option: -a required

Or the first three letters,e.g: -a req

Note: Only [Required] is generated if the property is defined in the Xml Metadata as required.


Generating Nullable Data Type for the properties

e.g.

public short? ReorderLevel {get;set;}

Use option -b

Note: Only the symbol "?" is generated if the property is defined in the Xml Metadata as Nullable.


Generating JsonProperty for the properties with camelCase

e.g.

 [JsonProperty(PropertyName = "CategoryID")]
 public int categoryID {get;set;} //PrimaryKey not null

use for for jsonProperty: -j use for for camelCase: -c camel

Note: to use PasCase, use the option: -c pas

Example to show all supported attributes:

  -a   key req json tab dm proto  display db

      1) key    add  [Key]  to  properties           
      2) req    add  [Required]  to  properties
      3) tab    add  [Table("Airlines")] to  class
      4)  dm   add [DataMember]   to  properties
            add [DataContract] to  class
      5)proto   add  [ProtoMember(n)] where n is a serial number to  properties
      6) display  add [Display(Name = "Airline Code")] to  properties
      7) db add the three  attributes  of key , req, tab as described above

	[Table("Airlines")]
	[DataContract]
	[ProtoContract]
	public partial class Airline
	{
	    [Key]
	    [Required]
	    [JsonProperty(PropertyName = "AirlineCode")]
	    [DataMember]
	    [ProtoMember(1)]
	    [Display(Name = "Airline Code")]
	    public virtual string AirlineCode {get;set;} //PrimaryKey not null

	    [JsonProperty(PropertyName = "Name")]
	    [DataMember]
	    [ProtoMember(2)]
	    [Display(Name = "Name")]
	    public virtual string Name {get;set;} 	
	  }
Clone this wiki locally