Esempio n. 1
0
        /// <summary>
        /// 如果有多个数据库操作的,请通过名称区分
        /// </summary>
        /// <param name="func"></param>
        /// <param name="connect"></param>
        /// <returns></returns>
        public DapperDbContext AddContext(Func <IDbConnection> func, ConnectTypeEnum connect = ConnectTypeEnum.None)
        {
            String name = connect.ToString();

            AddContext(func, name);
            return(this);
        }
Esempio n. 2
0
        private TResult ExecuteCommand <TResult>(ConnectTypeEnum connectTypeEnum, string connectionName, Func <IDatabase, TResult> callback)
        {
            var connect = GetConnection(connectTypeEnum, connectionName);

            if (connect != null)
            {
                try
                {
                    var db = connect.Multiplexer.GetDatabase();
                    return(callback.Invoke(db));
                }
                catch (Exception ex)
                {
                    ThrowExceptions(connect, ex);
                }
            }
            return(default);
Esempio n. 3
0
 public BaseRepository(ConnectTypeEnum sqlTypeEnum = ConnectTypeEnum.None) : this(sqlTypeEnum.ToString())
 {
 }