/// <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); }
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);
public BaseRepository(ConnectTypeEnum sqlTypeEnum = ConnectTypeEnum.None) : this(sqlTypeEnum.ToString()) { }