What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 16761 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Contexto Entity Framework ...
Johnplopez

Contexto Entity Framework

 Code Snippet posted by: Johnplopez | Posted on: 10/17/2012 | Category: C# Codes | Views: 267 | Status: [Member] | Points: 40 | Alert Moderator   


public partial class ContextoDAO
{
private static Dictionary<string, EliteEntities> _ListaContextoDatos;
private static Dictionary<string, EliteEntities> ListaContextoDatos
{
get { return ContextoDAO._ListaContextoDatos; }
set { ContextoDAO._ListaContextoDatos = value; }
}

static ContextoDAO()
{
ContextoDAO.ListaContextoDatos = new Dictionary<string, EliteEntities>();
}

private static EliteEntities CrearContextoDatos()
{
// Creación del contexto de datos.
EliteEntities oContextoDatos = new EliteEntities(ConfigurationManager.ConnectionStrings["EliteEntities"].ConnectionString);

// Definición de las reglas de actualización de datos en el contexto de datos.
//oContextoDatos.SectorActividad.MergeOption = MergeOption.OverwriteChanges;

// Retorno.
return oContextoDatos;
}

public static EliteEntities ContextoDatos
{
get
{
// Variables locales.
EliteEntities oContextoDatos = null;

if (HttpContext.Current != null && HttpContext.Current.Session !=
null)
{
// Application Client Web.
if (ListaContextoDatos.ContainsKey(
HttpContext.Current.Session.SessionID))
{
oContextoDatos =
ListaContextoDatos[HttpContext.Current.Session.SessionID];
}
else
{
oContextoDatos = ContextoDAO.CrearContextoDatos();
ListaContextoDatos.Add(
HttpContext.Current.Session.SessionID, oContextoDatos);
}
}
else
{
// Application Windows.
if (ListaContextoDatos.ContainsKey("AppliWin"))
{
oContextoDatos = ListaContextoDatos["AppliWin"];
}
else
{
oContextoDatos = ContextoDAO.CrearContextoDatos();
ListaContextoDatos.Add("AppliWin", oContextoDatos);
}
}

return oContextoDatos;
}
}

public static void BorrarContexto(string aIdContextoDatos)
{
if (ListaContextoDatos.ContainsKey(aIdContextoDatos))
{
ListaContextoDatos.Remove(aIdContextoDatos);
}
}

public static void Registrar()
{
ContextoDAO.ContextoDatos.SaveChanges();
}

}
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 3:27:08 PM