-
Notifications
You must be signed in to change notification settings - Fork 3
Attributes
Ricardo Barbosa edited this page Jul 18, 2013
·
66 revisions
Tells the MetadataGenerator that metadata about this class should be created.
When no property names are supplied, all properties are included.
[BreezeLocalizable]
public class TodoItem {...}
[BreezeLocalizable("Id", "Title")] //metadata will be only generated for Id and Title properties
public class TodoItem {...}
Maps to Breeze´s AutoGeneratedKeyType Enum and is used to inform how entity keys are generated upon creation time. (see BreezeJS AutoGeneratedKeyType for more info)
[BreezeLocalizable]
[BreezeAutoGeneratedKeyType(BreezeNoDbMetadataGeneratorEnums.AutoGeneratedKeyType.Identity)]
public class TodoItem {...}
This informs BreezeJS that this property does not exist in the database. BreezeJS will serialize it, send it to server, and listen for its changes, but it won't try to save it. If you are using EF and have 1:1 mappings and / or DTO´s you need custom business logic to handle these entities so make sure to add this attribute.
[BreezeLocalizable]
[BreezeAutoGeneratedKeyType(BreezeNoDbMetadataGeneratorEnums.AutoGeneratedKeyType.Identity)]
public class TodoItem {
[Key]
public int TodoItemId { get; set; }
public string Title { get; set; }
[BreezeUnmapped]
public bool IsDone { get; set; }
}
Navigation between entities and their associations.
[BreezeLocalizable]
[BreezeAutoGeneratedKeyType(BreezeNoDbMetadataGeneratorEnums.AutoGeneratedKeyType.Identity)]
public class TodoItem {
[Key]
public int TodoItemId { get; set; }
public string Title { get; set; }
public bool IsDone { get; set; }
public int TodoListId { get; set; } // Foreign key
// navigation property to item's parent TodoList
[BreezeNavigationProperty("TodoList_Items", "TodoListId")] // 1st parameter is the association name and the 2nd the foreign key
public virtual TodoList TodoList { get; set; }
}
Support for Key, Required and MaxLength validation attributes.
[BreezeLocalizable]
[BreezeAutoGeneratedKeyType(BreezeNoDbMetadataGeneratorEnums.AutoGeneratedKeyType.Identity)]
public class TodoItem {
[Key] // primary key
public int TodoItemId { get; set; }
[Required] // this property is required and BreezeJS will assign a validation property to it
[MaxLength(30)] // this property has also a MaxLength constraint so a maxlength validation property will be also created
public string Title { get; set; }
}