/// <summary> /// Executes a command on the data store /// </summary> /// <param name="command">The command to execute</param> /// <param name="connection">The connection to use</param> public virtual int ExecuteCommand(IDbCommand command, IDataConnection connection) { using (IDbConnection conn = connection.GetConnection()) { conn.Open(); command.Connection = conn; try { FireEvent(command, connection); return command.ExecuteNonQuery(); } catch (Exception e) { //throw new QueryException(e, command); throw e; } } }
public MainWindowVM(IDataConnection dataConnection) { this.dataConnection = dataConnection; dataConnection.DataReceived += PlotData; dataConnection.IsConnectedChanged += HandleConnectionChanged; ConnectCommand.CanExecute(!dataConnection.IsConnected); ResetCommand.CanExecute(dataConnection.IsConnected); }
public virtual IQueryData ExecuteCommandQueryAction(IDbCommand command, IDataConnection connection, IDbConnection r) { QueryData toReturn = new QueryData(r, command); return(toReturn); }
/// <summary> /// Execute a single-row query asynchronously using .NET 4.5 Task. /// </summary> /// <typeparam name="TFirst">The first type in the record set.</typeparam> /// <typeparam name="TSecond">The second type in the record set.</typeparam> /// <typeparam name="TConn"></typeparam> /// <typeparam name="TReturn">The combined type to return.</typeparam> /// <param name="cnn">The connection to query on.</param> /// <param name="sql">The SQL to execute for the query.</param> /// <param name="map">The function to map row types to the return type.</param> /// <param name="param">The parameters to pass, if any.</param> /// <param name="transaction">The transaction to use, if any.</param> /// <param name="commandTimeout">The command timeout (in seconds).</param> /// <param name="commandType">The type of command to execute.</param> /// <param name="splitOn">The field we should split and read the second object from (default: "Id").</param> /// <param name="cancellationToken"></param> /// <returns></returns> public static async Task <TReturn> SaveFirstOrDefaultAsync <TFirst, TSecond, TConn, TReturn>(this IDataConnection <TConn> cnn, string sql, Func <TFirst, TSecond, TReturn> map, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null, string splitOn = "Id", CancellationToken cancellationToken = default) where TConn : DbConnection { var timeout = commandTimeout ?? cnn.DefaultCommandTimeout; var connection = await cnn.GetOpenConnectionAsync(cancellationToken).ConfigureAwait(false); var retryPolicy = cnn.RetryPolicy?.GetStandardSaveQueryRetryPolicy(); transaction = transaction ?? cnn.CurrentTransaction; var items = await QueryAsync(connection, sql, map, param, transaction, timeout, commandType, retryPolicy, splitOn, cancellationToken).ConfigureAwait(false); return(items.FirstOrDefault()); }
public EmployeesService(IDataConnection dataConnection, IAuthorization authorization) { _dataConnection = dataConnection; _authorization = authorization; }
public MongoDBReader(string datasourcename, string databasename, IDMEEditor pDMEEditor, IDataConnection pConn, List <EntityField> pfields = null) : base(datasourcename, pDMEEditor, pConn, pfields) { CurrentDatabase = databasename; if (string.IsNullOrWhiteSpace(CurrentDatabase) == false) { OpenStore(ConnProp.Url); } }
/// <summary> /// will use windows auth /// </summary> /// <param name="Server"></param> /// <param name="Catalog"></param> public PostgreSQLConnection(string Server, string Catalog, bool isTransactional = false, IDataConnection con = null) : this(string.Format("Server={0};Port=5432;Database={1};User Id={2};Password={3};", Server, Catalog), isTransactional, con) { }
public DefaultPeerRepository(IDataConnection connection, ILoggerFactory loggerFactory) { _connection = connection; _logger = loggerFactory.CreateLogger <DefaultPeerRepository>(); }
internal DataConnectionManager(short shardId, IDataProviderServiceFactory dataProviderServices, IDataConnection connectionConfig, string connectionName, ILogger logger) { this._logger = logger; this._dataProviderServices = dataProviderServices; this._connectionName = connectionName; _shardId = shardId; _connectionConfig = connectionConfig; _resiliencePolicy = GetConnectionResiliencePolicy(); }
public TypeParser(IDataConnection connection) { _connection = connection; }
public AdvantageDatabaseCommandGenerator(IDataConnection conn) : base(conn) { }
public VehicleTypeRepository(IDataConnection dataConnection) : base(dataConnection.ConnectionString, dataConnection.DatabaseType, dataConnection.DbProviderFactory) { }
public TransferService(IList <TransferLimit> limits, IDataConnection data, ICurrencyService currencyService) { _transferLimits = limits; _dataConnection = data; _currencyService = currencyService; }
public EventSlotRepository(IDataConnection dataConnection) { _dataConnection = dataConnection; _eventParticipantRepository = new EventParticipantRepository(_dataConnection); }
public SqlServerCommandGenerator(IDataConnection connection) : base(connection) { }
public LoadAllData(IDataConnection dbContext) { this.dbContext = dbContext; }
public PersonFileFormatter(IDataConnection <IList <PersonDto> > con) { this.con = con; }
private void FireEvent(IDbCommand command, IDataConnection connection) { if (CommandExecuting != null) CommandExecuting(this, new CommandExecutingEventArgs(command, connection)); }
public PostDetails(string title, IDataConnection dataConnection) { InitializeComponent(); _dataConnection = dataConnection; SpawnNewPostForm(title); }
public SomeOtherService(IDataConnection <SomeOtherService> db) { _db = db; }
/// <summary> /// Pre-Condition: A data connection that implements the interface IDataConnection. /// Description: This constructor will save a local instance of the data connection object. /// Extract and save a local instance of the Database connection stored in the data connection object. /// Create a new instance of a dataset to be used locally. /// </summary> /// <param name="pDataconnection"></param> public Crud(IDataConnection pDataconnection) { _dataConnection = pDataconnection; _dbConnection = _dataConnection.DbConnection(); _dataSet = new DataSet(); }
private void establishMySQLConnection() { #if DEBUG database = "blau"; uid = "blau"; password = "******"; #elif TESTING //server = "10.211.55.6"; database = "blau_dev"; uid = "blau"; password = "******"; lblTestModeWarning.Visible = true; #else database = "blau"; uid = "blau"; password = "******"; #endif connection = new MySqlDatabaseConnection(DB_SERVER, database, uid, password); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerConnection"/> /// </summary> /// <param name="Server">The server.</param> /// <param name="Catalog">The catalog.</param> /// <param name="User">The user.</param> /// <param name="Password">The password.</param> public MsSqlServerConnection(string Server, string Catalog, string User, string Password, bool isTransactional = false, IDataConnection con = null) : this(string.Format("Data Source={0};Initial Catalog={1};User Id={2};Password={3};", Server, Catalog, User, Password), isTransactional, con) { }
public TokenStorage(IDataConnection dataConnection, IDateHelper dateHelper) { this.dataConnection = dataConnection; this.dateHelper = dateHelper; }
/// <summary> /// will use windows auth /// </summary> /// <param name="Server"></param> /// <param name="Catalog"></param> public MsSqlServerConnection(string Server, string Catalog, bool isTransactional = false, IDataConnection con = null) : this(string.Format("Data Source={0};Initial Catalog={1};Integrated Security=true;", Server, Catalog), isTransactional, con) { }
public void WithSetup_executes_setup_within_transaction_when_no_preference_specified([Frozen] IGetsDataConnection sessionProvider, PersistenceTestBuilder sut, [NoRecursion] SampleEntity entity, IDataConnection session, IGetsTransaction tranFactory, ITransaction tran) { Mock.Get(sessionProvider).Setup(x => x.GetConnection()).Returns(session); Mock.Get(session).Setup(x => x.GetTransactionFactory()).Returns(tranFactory); Mock.Get(tranFactory).Setup(x => x.GetTransaction()).Returns(tran); var action = GetSetup(getter => { /* Noop */ }); var result = (PersistenceTestBuilder <SampleEntity>)AsSetupChooser(sut) .WithSetup(action) .WithEntity(entity); result.Setup(session); Mock.Get(tranFactory).Verify(x => x.GetTransaction(), Times.Once); }
public static void InitializeConnections() { Connection = new SqlConnector(); }
/// <summary> /// Initializes a new instance of the <see cref="DataStore"/> class. /// </summary> /// <param name="Connection">The data connection.</param> /// <param name="ExecuteComamands">The command executor.</param> /// <param name="TypeParser">The type parser.</param> public DataStore(IDataConnection Connection, IExecuteDatabaseCommand ExecuteComamands) : this(Connection) { this.ExecuteCommands = ExecuteComamands; }
public CommandExecutingEventArgs(IDbCommand command, IDataConnection connection) { this.Command = command; this.Connection = connection; }
public NumberService(IDataConnection dataConnection) { _dataConnection = dataConnection; }
public List <TEntity> GetAll() { using (IDataConnection connection = _connectionFactory.Create()) { return(connection.From <TEntity>().ToList()); } }
protected void FireExecutedEvent(IDbCommand command, IDataConnection connection, IDbConnection conn) { CommandExecuted?.Invoke(this, new CommandExecutingEventArgs(command, connection, conn)); }
public DatabaseCommandGenerator(IDataConnection connection) { _connection = connection; TypeParser = new TypeParser(_connection); }
public UserDataRepository(IDataConnection connection) { DBContext = new Database(connection.ConnectionString, connection.DatabaseType, connection.DbProviderFactory); InternalContext = DBContext; }
public DataRepository(IDataConnection dataConnection) { DataConnection = dataConnection as ISqliteDataConnection; }
public PatientRepository(IDataConnection dataConnection) { this._dataConnection = dataConnection; }
/// <summary> /// Initializes a new instance of the <see cref="DataStore"/> class. /// </summary> /// <param name="Connection">The data connection.</param> /// <param name="ExecuteComamands">The command executor.</param> /// <param name="TypeParser">The type parser.</param> public DataStore(IDataConnection Connection, IExecuteDatabaseCommand ExecuteComamands, ITypeInformationParser TypeParser) : this(Connection) { this.ExecuteCommands = ExecuteComamands; this.TypeInformationParser = TypeParser; }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { data = new OracleDataConnection(); ctrlCustomer.Data = data; ctrlSales.Data = data; ctrlProduction.Data = data; Login(); }
private void InitConnection() { string dbserver = ConfigurationManager.AppSettings["DBServer"]; string dbname = ConfigurationManager.AppSettings["DBName"]; string dbusername = ConfigurationManager.AppSettings["DBUsername"]; string dbpassword = ConfigurationManager.AppSettings["DBPassword"]; Connection = DLAPI.GetConnection(dbserver, dbname, dbusername, dbpassword); }
public Customer(string customerNumber, IDataConnection connection) { this.CustomerNumber = customerNumber; this.Connection = connection; loadData(); }
public CarrierActions(IDataConnection connection) { this.connection = connection; }
public EventParticipantRepository(IDataConnection dataConnection) { _dataConnection = dataConnection; }
/// <summary> /// Hàm khởi tạo BaseConnect khai báo dbContext /// </summary> /// <param name="dbContext"></param> public BaseData(IDataConnection <T> dataConnection) { _dataConnection = dataConnection; }
public LoadSpecificData(IDataConnection dbContext) { this.dbContext = dbContext; }
/// <summary> /// Получить список значений таблицы /// </summary> /// <returns>Список значений</returns> public async Task <List <TEntity> > GetAll() { using (IDataConnection connection = _connectionFactory.Create()) { return(await connection.From <TEntity>().ToListAsync()); } }
public virtual DataSet ExecuteQuery(IDbCommand command, IDataConnection connection) { DataSet _datasetForStore = new DataSet(); IDbConnection conn = connection.GetConnection(); if (conn.State != ConnectionState.Open) conn.Open(); if (connection.IsTransactional) command.Transaction = connection.GetTransaction; command.Connection = conn; command.CommandTimeout = 10000; IDataAdapter adapter = connection.GetDataAdapter(command); try { FireEvent(command, connection); adapter.Fill(_datasetForStore); } catch (Exception e) { //throw new QueryException(e, command); throw e; } finally { if (!connection.IsTransactional) conn.Close(); } return _datasetForStore; }
/// <summary> /// Executes a command and returns the result /// </summary> /// <param name="command">The command to execute</param> /// <param name="connection">The connection to use</param> /// <returns></returns> public virtual QueryData ExecuteCommandQuery(IDbCommand command, IDataConnection connection) { QueryData toReturn = new QueryData(); IDbConnection conn = connection.GetConnection(); if (conn.State != ConnectionState.Open) conn.Open(); if (connection.IsTransactional) command.Transaction = connection.GetTransaction; command.Connection = conn; command.CommandTimeout = 10000; IDataReader reader; try { FireEvent(command, connection); using (reader = command.ExecuteReader()) { if (!_mappings.ContainsKey(command.CommandText)) { _mappings[command.CommandText] = new Dictionary<string, int>(); DataTable schema = reader.GetSchemaTable(); if (schema != null) { for (int i = 0; i < schema.Rows.Count; i++) { _mappings[command.CommandText].Add(schema.Rows[i]["ColumnName"].ToString().ToUpper(), i); } } } toReturn.SetFieldMappings(_mappings[command.CommandText]); while (reader.Read()) { object[] values = new object[reader.FieldCount]; reader.GetValues(values); toReturn.AddRowData(values); } } } catch (Exception e) { //throw new QueryException(e, command); throw e; } finally { if (!connection.IsTransactional) conn.Close(); } toReturn.QuerySuccessful = true; return toReturn; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerConnection"/> class. /// </summary> /// <param name="ConnectionString">The connection string.</param> public MsSqlServerConnection(string ConnectionString, bool isTransactional = false, IDataConnection con = null) { _commandGenerator = new MsSqlServerCommandGenerator(); _connectionString = ConnectionString; _tConverter = new TSqlTypeConverter(); _Istransactional = isTransactional; _connection = new SqlConnection(_connectionString); if (con != null) { _Istransactional = con.IsTransactional; _connection = con.GetConnection() as SqlConnection; if (con.IsTransactional) { _transaction = con.GetTransaction; } } }