Pages

Showing posts with label Entity Framework. Show all posts
Showing posts with label Entity Framework. Show all posts

Wednesday, January 14, 2015

DataAnnotations Cheat Sheet (esp)

He buscado por todo lado un Cheat Sheet como este para tener todas las opciones a mano pero no pude encontrar nada. Asi que arme uno propio, espero que les sirva de ayuda:


DataAnnotations Cheat Sheet v1.0


Nombre: AssociationAttribute

Descripcion: Especifica que un miembro de la entidad representa una relación, como una relacion de llave foranea.
Uso: [Association(Name, OtherKey, ThisKey)]
Ejemplo:
[Table(Name = "Clientes")]
public partial class Cliente
{
    [Column(IsPrimaryKey = true)]
    public string ClienteID;
    // ...
    private EntitySet<Pedido> _Pedidos;
    [Association(Storage = "_Pedidos", OtherKey = "ClienteID")]
    public EntitySet<Pedido> Pedidos

    {
        get { return this._Pedidos; }
        set { this._Pedidos.Assign(value); }
    }
}

Nombre: BindableTypeAttribute
Descripcion: Especifica si es que un tipo es tipicamente usado para hacer un   binding.
Uso: [BindableType(IsBindable = bool)]
Ejemplo:
  [BindableType(IsBindable = false)]
  public enum EstadoDeEntidad
  {
    Detached = 1,
    SinCambios = 2,
    Adicionado = 4,
    Borrado = 8,
    Modificado= 16,
  }


Wednesday, May 7, 2014

Entity Framework DataAnnotations Cheat Sheet

I have been looking everywhere for a Cheat Sheet like this but could not find anything, So I had to make my own, I hope you find it useful:


DataAnnotations Cheat Sheet v1.0


Name: AssociationAttribute

Description: Specifies that an entity member represents a data relationship, such as a foreign key relationship.
Usage: [Association(Name, OtherKey, ThisKey)]
Example:
[Table(Name = "Customers")]
public partial class Customer
{
    [Column(IsPrimaryKey = true)]
    public string CustomerID;
    // ...
    private EntitySet<Order> _Orders;
    [Association(Storage = "_Orders", OtherKey = "CustomerID")]
    public EntitySet<Order> Orders
    {
        get { return this._Orders; }
        set { this._Orders.Assign(value); }
    }
}

Name: BindableTypeAttribute
Description: Specifies whether a type is typically used for binding.
Usage: [BindableType(IsBindable = bool)]
Example:
  [BindableType(IsBindable = false)]
  public enum EntityState
  {
    Detached = 1,
    Unchanged = 2,
    Added = 4,
    Deleted = 8,
    Modified = 16,
  }