Maps a property/field member constructor parameter to FaunaDB object property while encoding/deconding an object. If this attribute if not specified the property/field name constructor parameter name will be used instead. More...
Public Member Functions | |
FaunaFieldAttribute (string name) | |
Properties | |
string | Name [get] |
The name of the property when encoding/decoding objects. More... | |
object | DefaultValue [get, set] |
The default value used for a missing property when decoding an object. More... | |
Maps a property/field member constructor parameter to FaunaDB object property while encoding/deconding an object. If this attribute if not specified the property/field name constructor parameter name will be used instead.
class Car { [FaunaField("model")] public string Model { get; set; }
[FaunaField("manufacturer")] public string Manufacturer { get; set; } }
var car = new Car { Model = "DeLorean DMC-12", Manufacturer = "DeLorean Motor Company" };
var encoded = Encoder.Encode(car);
//encoded will be equivalent to:
ObjectV.With("model", "DeLorean DMC-12", "manufacturer", "DeLorean Motor Company")
class Product { private string description; private double price;
[FaunaConstructor] public Product([FaunaField("Description")] string description, [FaunaField("Price")] double price) { this.description = description; this.price = price; } }
Definition at line 41 of file Attributes.cs.
FaunaDB.Types.FaunaFieldAttribute.FaunaFieldAttribute | ( | string | name | ) |
Definition at line 53 of file Attributes.cs.
|
getset |
The default value used for a missing property when decoding an object.
Definition at line 51 of file Attributes.cs.
|
get |
The name of the property when encoding/decoding objects.
Definition at line 46 of file Attributes.cs.