-
Notifications
You must be signed in to change notification settings - Fork 3
Attributes
Ricardo Barbosa edited this page Jul 17, 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 keys are generated to entities 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.
[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 attributes.
[BreezeLocalizable]
[BreezeAutoGeneratedKeyType(BreezeNoDbMetadataGeneratorEnums.AutoGeneratedKeyType.Identity)]
public class TodoItem {
[Key] // primary key
public int TodoItemId { get; set; }
[Required] // this property is required and will be considered as a validation property for BreezeJS
[MaxLength(30)] // this property has also a MaxLength constraint so it will be considered as a validation property also
public string Title { get; set; }
}