Skip to content
Ricardo Barbosa edited this page Jul 21, 2013 · 66 revisions

BreezeLocalizable

Tells SummerBreeze to generate metadata about this class.

When no property names are supplied, all properties are included.

The first optional boolean parameter informs if all properties should me marked as unmaped, by default it´s false.

    [BreezeLocalizable]
    public class TodoItem {...}

    [BreezeLocalizable("Id", "Title")] //metadata will be only generated for Id and Title properties 
    public class TodoItem {...} 

    [BreezeLocalizable(true)] // all data properties will be marked as unmapped
    public class TodoItem {...}

BreezeAutoGeneratedKeyType

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(SummerBreezeEnums.AutoGeneratedKeyType.Identity)]
    public class TodoItem {...}

BreezeUnmapped

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 with DTO´s you will surely need custom business logic to handle these entities. Make sure to add this attribute to all your properties by passing true to BreezeLocalizable attribute constructor.

   [BreezeLocalizable]
   [BreezeAutoGeneratedKeyType(SummerBreezeEnums.AutoGeneratedKeyType.Identity)]
   public class TodoItem {
   
   [Key]
   public int TodoItemId { get; set; }
   
   public string Title { get; set; }
   
   [BreezeUnmapped]
   public bool IsDone { get; set; }
}

BreezeNavigationProperty

Navigation between entities and their associations.

   [BreezeLocalizable]
   [BreezeAutoGeneratedKeyType(SummerBreezeEnums.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; }

}

DataAnnotations

Support for Key, Required and MaxLength validation attributes.

   [BreezeLocalizable]
   [BreezeAutoGeneratedKeyType(SummerBreezeEnums.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; }
}

Clone this wiki locally