-
Notifications
You must be signed in to change notification settings - Fork 22
howto
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;}
}
- home
- Announcing V6.0.0
- Features
- Getting started with c# generation
- Http Connection
- Using Parameter file
- User Defined Attributes
- Controlling c# code generation
- Model Filter
- Enable Nullable Reference type of c# 8
- Class with Init-Only Properties (c# 9)
- Generating Constructor
- Record-Type (c# 9)
- Name Map
- Securing Password
- Using Proxy Server
- Using Plugin Attributes
- Developing with OData2Poco
- Examples in dotnetfiddle.net
- CommandLine-Reference
- AttributeExamples
- typescript generation
- Help Screen
- How to
- New Feature 4.2.1
Samples of generated code: