Skip to content

Instantly share code, notes, and snippets.

@jesuscampos
Last active December 8, 2017 20:46
Show Gist options
  • Save jesuscampos/d81eb964ce64648f3ed2f9d2f74bf403 to your computer and use it in GitHub Desktop.
Save jesuscampos/d81eb964ce64648f3ed2f9d2f74bf403 to your computer and use it in GitHub Desktop.
// Carga diferida (activada en Entity Framework por defecto)
MyContext myContext = new MyContext();
IList<Cliente> clientes = myContext.Clientes.ToList();
IList<Pedido> pedidos = clientes.FirstOrDefault().Pedidos.ToList();
// Carga explícita
MyContext myContext = new MyContext();
IList<Cliente> clientes = myContext.Clientes.ToList();
myContext.Entry(clientes).Reference("Direccion").Load();
myContext.Entry(clientes).Collection("Pedidos").Load();
// Carga instantánea
MyContext myContext = new MyContext();
IList<Cliente> clientes = myContext.Clientes.Where(c => c.IdCliente == 1).Include("Pedidos.DetallesPedidos").ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment