private static void ProfilingInserts(ISisoDatabase database, int numOfCustomers, int numOfItterations) { var durations = new List<TimeSpan>(); var stopWatch = new Stopwatch(); for (var c = 0; c < numOfItterations; c++) { var customers = CustomerFactory.CreateCustomers(numOfCustomers); stopWatch.Start(); InsertCustomers(customers, database); stopWatch.Stop(); durations.Add(stopWatch.Elapsed); Console.WriteLine("TotalSeconds = {0}", stopWatch.Elapsed.TotalSeconds); stopWatch.Reset(); } using (var unitOfWork = database.CreateUnitOfWork()) { var rowCount = unitOfWork.Count<Customer>(); Console.WriteLine("Total rows = {0}", rowCount); } }
private static void InsertCustomers(IEnumerable<Customer> customers, ISisoDatabase database) { using (var unitOfWork = database.CreateUnitOfWork()) { unitOfWork.InsertMany(customers); unitOfWork.Commit(); } }
public DbSchemas(ISisoDatabase db, IDbSchemaUpserter dbSchemaUpserter) { Ensure.That(db, "db").IsNotNull(); Ensure.That(dbSchemaUpserter, "dbSchemaUpserter").IsNotNull(); Db = db; DbSchemaUpserter = dbSchemaUpserter; }
public SisoDbContactRepository() { string connectionString = WebConfigurationManager.ConnectionStrings["default"] .ConnectionString; var connectionInfo = new SisoConnectionInfo( string.Format(@"sisodb:provider=Sql2008||plain:{0}", connectionString)); var factory = new SisoDbFactory(); _database = factory.CreateDatabase(connectionInfo); _database.CreateIfNotExists(); }
public Resources() { //Func should resolve the SAME ISisoDatabase each time _db = new Sql2012DbFactory().CreateDatabase(new Sql2012ConnectionInfo("Demo")); _db.CreateIfNotExists(); DbResolver = () => _db; //Simple key-value map for acceptable structure types _structureTypes = GetStructureTypes().ToDictionary(t => t.Name); StructureTypeResolver = name => _structureTypes[name]; }
public SqlDbSchemaUpserter(ISisoDatabase db, ISqlStatements sqlStatements) { Ensure.That(db, "db").IsNotNull(); Ensure.That(sqlStatements, "sqlStatements").IsNotNull(); Db = db; StructuresDbSchemaBuilder = new SqlDbStructuresSchemaBuilder(sqlStatements); IndexesDbSchemaBuilder = new SqlDbIndexesSchemaBuilder(sqlStatements); UniquesDbSchemaBuilder = new SqlDbUniquesSchemaBuilder(sqlStatements); IndexesDbSchemaSynchronizer = new SqlDbIndexesSchemaSynchronizer(sqlStatements); UniquesDbSchemaSynchronizer = new SqlDbUniquesSchemaSynchronizer(sqlStatements); }
public override IDbClient GetTransactionalDbClient(ISisoDatabase db) { var connection = ConnectionManager.OpenClientConnection(db.ConnectionInfo); var transaction = Transactions.ActiveTransactionExists ? null : connection.BeginTransaction(IsolationLevel.ReadCommitted); return new Sql2005DbClient( GetAdoDriver(), connection, transaction, ConnectionManager, SqlStatements, db.Pipe); }
public override IDbClient GetNonTransactionalDbClient(ISisoDatabase db) { IDbConnection connection = null; if (Transactions.ActiveTransactionExists) Transactions.SuppressOngoingTransactionWhile(() => connection = ConnectionManager.OpenClientConnection(db.ConnectionInfo)); else connection = ConnectionManager.OpenClientConnection(db.ConnectionInfo); return new Sql2005DbClient( GetAdoDriver(), connection, null, ConnectionManager, SqlStatements, db.Pipe); }
private static void ProfilingUpdateMany(ISisoDatabase database, int customerNoFrom, int customerNoTo) { var stopWatch = new Stopwatch(); stopWatch.Start(); using (var session = database.BeginSession()) { session.UpdateMany<Customer>( c => c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo, customer => { customer.Firstname += "Udated"; }); } stopWatch.Stop(); Console.WriteLine("TotalSeconds = {0}", stopWatch.Elapsed.TotalSeconds); using (var rs = database.BeginSession()) { var rowCount = rs.Query<Customer>().Count(); Console.WriteLine("Total rows = {0}", rowCount); } }
private static void ProfilingInserts(ISisoDatabase database, int numOfCustomers, int numOfItterations) { var stopWatch = new Stopwatch(); for (var c = 0; c < numOfItterations; c++) { var customers = CustomerFactory.CreateCustomers(numOfCustomers); stopWatch.Start(); InsertCustomers(customers, database); stopWatch.Stop(); Console.WriteLine("TotalSeconds = {0}", stopWatch.Elapsed.TotalSeconds); stopWatch.Reset(); } using (var rs = database.BeginSession()) { var rowCount = rs.Query<Customer>().Count(); Console.WriteLine("Total rows = {0}", rowCount); } }
public SetupController(ISisoDatabase database) { _database = database; }
private static int SingleOrDefault(ISisoDatabase database, int customerNoFrom, int customerNoTo) { using (var session = database.BeginSession()) { return session.Query<Customer>().Where(c => c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544").SingleOrDefault() == null ? 0 : 1; } }
private static int GetCustomersAsJsonViaIndexesTable(ISisoDatabase database, int customerNoFrom, int customerNoTo) { var d = new DateTime(2012, 1, 1); using (var session = database.BeginSession()) { return session.Query<Customer>().OrderBy(c => c.Lastname).Where(c => c.Score > 10 && c.IsActive && c.CustomerSince > d && c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544").ToEnumerableOfJson().Count(); } }
private static int GetCustomersViaSpExp(ISisoDatabase database, int customerNoFrom, int customerNoTo) { var d = new DateTime(2012, 1, 1); using (var session = database.BeginSession()) { return session.Advanced.NamedQuery<Customer>("CustomersViaSP", c => c.Score > 10 && c.IsActive && c.CustomerSince > d && c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544").ToArray().Length; } }
private static int GetCustomersViaSpExp(ISisoDatabase database, int customerNoFrom, int customerNoTo) { using (var session = database.BeginSession()) { return session.Advanced.NamedQuery<Customer>("CustomersViaSP", c => c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544").ToArray().Length; } }
internal Sql2012Session(ISisoDatabase db) : base(db) {}
public override IServerClient GetServerClient(ISisoDatabase db) { return new Sql2005ServerClient(GetAdoDriver(), db.ConnectionInfo, ConnectionManager, SqlStatements); }
private static int GetAllCustomers(ISisoDatabase database) { using (var session = database.BeginSession()) { return session.Query<Customer>().ToEnumerable().Count(); } }
private static void InsertCustomers(IEnumerable<Customer> customers, ISisoDatabase database) { using (var unitOfWork = database.BeginSession()) { unitOfWork.InsertMany(customers); } }
private static void InsertCustomers(int numOfItterations, int numOfCustomers, ISisoDatabase database) { for (var c = 0; c < numOfItterations; c++) { var customers = CustomerFactory.CreateCustomers(numOfCustomers); InsertCustomers(customers, database); } }
private static int GetCustomersAsJsonViaIndexesTable(ISisoDatabase database, int customerNoFrom, int customerNoTo) { using (var session = database.BeginSession()) { return session.Query<Customer>().Where(c => c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544").ToEnumerableOfJson().Count(); } }
internal SqlCe4Session(ISisoDatabase db) : base(db) {}
protected TestContextBase(ISisoDatabase db) { Database = db; }
public virtual void NotifyRolledback(ISisoDatabase db, Guid sessionId) { foreach (var handler in OnRolledbackHandlers) handler.Invoke(db, sessionId); }
public virtual void NotifyCommitted(ISisoDatabase db, Guid sessionId) { foreach (var handler in OnCommittedHandlers) handler.Invoke(db, sessionId); }
private static void UpsertSp(ISisoDatabase database, int customerNoFrom, int customerNoTo) { using (var session = database.BeginSession()) { session.Advanced.UpsertNamedQuery<Customer>("CustomersViaSP", qb => qb.Where(c => c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544")); } }
private static int GetAllCustomersAsJson(ISisoDatabase database) { return database.UseOnceTo().Query<Customer>().ToEnumerableOfJson().Count(); }
private static int GetCustomersViaSpRaw(ISisoDatabase database, int customerNoFrom, int customerNoTo) { var d = new DateTime(2012, 1, 1); using (var session = database.BeginSession()) { var q = new NamedQuery("CustomersViaSP"); q.Add(new DacParameter("p0", 10)); q.Add(new DacParameter("p1", true)); q.Add(new DacParameter("p2", d)); q.Add(new DacParameter("p3", customerNoFrom)); q.Add(new DacParameter("p4", customerNoTo)); q.Add(new DacParameter("p5", "The delivery street #544")); return session.Advanced.NamedQuery<Customer>(q).ToArray().Length; } }
protected SqlServerSession(ISisoDatabase db) : base(db) {}
private static void UpsertSp(ISisoDatabase database, int customerNoFrom, int customerNoTo) { var d = new DateTime(2012, 1, 1); using (var session = database.BeginSession()) { session.Advanced.UpsertNamedQuery<Customer>("CustomersViaSP", qb => qb.OrderBy(c => c.Lastname).Where(c => c.Score > 10 && c.IsActive && c.CustomerSince > d && c.CustomerNo >= customerNoFrom && c.CustomerNo <= customerNoTo && c.DeliveryAddress.Street == "The delivery street #544")); } }