private static void OnDaoContextConnectionStringSet(DaoContext context, string logicalName) { if (DaoContextConnectionStringSet != null) { DaoContextConnectionStringSet(context, logicalName); } }
/// <summary> /// Get the current DaoContext instance for the specified logicalName. /// If a DaoContext has already been instantiated for the specified logicalName /// the connection string is updated with the one specified. /// </summary> /// <param name="contextName">The name of the DaoContext to retrieve.</param> /// <param name="connString">The connection string to assign to the specified</param> /// <returns>DaoContext instance.</returns> public static DaoContext Get(string contextName, string connString) { if (contexts.ContainsKey(contextName)) { return(contexts[contextName]); } // if no connection string was specified check if this logical name has // been initialized string connectionString = connString; if (string.IsNullOrEmpty(connectionString)) { connectionString = GetContextConnectionString(contextName); } DatabaseAgent agent = DatabaseAgent.CreateAgent(GetContextDatabaseType(contextName), connectionString); DaoContext dao = new DaoContext(); dao.DatabaseAgent = agent; if (!contexts.ContainsKey(contextName)) { contexts.Add(contextName, dao); } else { contexts[contextName] = dao; } OnDaoContextConnectionStringSet(dao, contextName); return(dao); }
public DaoStub(int id) { this.Id = id; T proxy = new T(); this.DatabaseAgent = DaoContext.Get(proxy.DataContextName).DatabaseAgent; }
public DaoObjectCollection(DaoSearchFilter filter) : base() { this.filter = filter; this.pagedIds = new Book <long>(new List <long>(), DefaultPageSize); T proxy = new T(); this.agent = DaoContext.Get(proxy.DataContextName).DatabaseAgent; this.GetIds(); }
public void Add(string contextName, DaoContext daoContext) { this.contexts.Add(contextName, daoContext); }
public void SetConnectionString() { DaoContext context = DaoContext.Get(contextName, GetConnectionString()); OnDaoContextConnectionStringSet(context, ContextName); }