/// <summary>
        /// 获取会话
        /// </summary>
        /// <param name="useProxy">是否使用会话代理</param>
        /// <returns></returns>
        public static ISession GetSession()
        {
            ISession session    = null;
            var      connection = DataSource();

            if (SessionProxy)
            {
                session         = new SessionProxy(new Session(connection));
                session.Timeout = connection.ConnectionTimeout;
            }
            else
            {
                session         = new Session(connection);
                session.Timeout = connection.ConnectionTimeout;
            }
            return(session);
        }
Exemple #2
0
        /// <summary>
        /// 获取会话
        /// </summary>
        /// <param name="name">数据源</param>
        /// <returns></returns>
        public static ISession GetSession(string name = null)
        {
            ISession session    = null;
            var      dataSource = GetDataSource(name);
            var      connection = dataSource.Source();

            if (StaticProxy)
            {
                session = new SessionProxy(new Session(dataSource.Source(), dataSource.Type))
                {
                    Timeout  = connection.ConnectionTimeout,
                    Buffered = true,
                };
            }
            else
            {
                session = new Session(connection, dataSource.Type)
                {
                    Timeout  = connection.ConnectionTimeout,
                    Buffered = true,
                };
            }
            return(session);
        }