.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

KeyAttribute.AutoGenerate Property

Gets or sets whether the key is generated automatically.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public bool AutoGenerate { get; set; }
Public Property AutoGenerate As Boolean
public bool AutoGenerate { get; set; }
Public Property AutoGenerate As Boolean

Property Value

Type Description
Boolean

true to generate the key automatically; otherwise, false.

Property Value

Type Description
Boolean

true to generate the key automatically; otherwise, false.

Remarks

Automatic key generation is supported for Int32, Int64 and Guid type keys. Guid key values are always generated on the client side, while Int32 and Int64 key values are generated using database facilities. Based on the database type, automatic key generation is implemented using identity/autonumber/auto-increment fields or sequences. If a database doesn't provide any of these facilities, key values are generated by XPO.

Decorate a key property with the KeyAttribute and pass the attribute's parameter to specify this property as shown below.

public class Customer : XPBaseObject {
    int oid;
    [Key(true)]
    public int Oid { 
        get { return oid; } 
        set { SetPropertyValue(nameof(Oid), ref oid, value); } 
    }
    // ...
}
See Also