Example #1
0
 private static void OnDaoContextConnectionStringSet(DaoContext context, string logicalName)
 {
     if (DaoContextConnectionStringSet != null)
     {
         DaoContextConnectionStringSet(context, logicalName);
     }
 }
Example #2
0
        /// <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);
        }
Example #3
0
        public DaoStub(int id)
        {
            this.Id = id;
            T proxy = new T();

            this.DatabaseAgent = DaoContext.Get(proxy.DataContextName).DatabaseAgent;
        }
Example #4
0
        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();
        }
Example #5
0
 public void Add(string contextName, DaoContext daoContext)
 {
     this.contexts.Add(contextName, daoContext);
 }
Example #6
0
        public void SetConnectionString()
        {
            DaoContext context = DaoContext.Get(contextName, GetConnectionString());

            OnDaoContextConnectionStringSet(context, ContextName);
        }