Пример #1
0
 private static void InsertCustomers(IEnumerable <Customer> customers, ISisoDatabase database)
 {
     using (var unitOfWork = database.BeginSession())
     {
         unitOfWork.InsertMany(customers);
     }
 }
Пример #2
0
 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());
     }
 }
Пример #3
0
 private static int GetAllCustomers(ISisoDatabase database)
 {
     using (var session = database.BeginSession())
     {
         return(session.Query <Customer>().ToEnumerable().Count());
     }
 }
Пример #4
0
 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);
     }
 }
Пример #5
0
        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"));
            }
        }
Пример #6
0
        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());
            }
        }
Пример #7
0
 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"));
     }
 }
Пример #8
0
 public static void should_have_valid_structures <T>(this ISisoDatabase db, Action <T> validationRule) where T : class
 {
     using (var rs = db.BeginSession())
     {
         foreach (var structure in rs.Query <T>().ToEnumerable())
         {
             validationRule(structure);
         }
     }
 }
Пример #9
0
 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);
     }
 }
Пример #10
0
        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);
            }
        }
Пример #11
0
        public static void should_have_ids <T>(this ISisoDatabase db, params object[] ids) where T : class
        {
            Ensure.That(ids, "ids").HasItems();

            using (var session = db.BeginSession())
            {
                foreach (var id in ids)
                {
                    session.GetById <T>(id).ShouldNotBeNull();
                }
            }
        }
Пример #12
0
        private static int GetCustomersViaSpRaw(ISisoDatabase database, int customerNoFrom, int customerNoTo)
        {
            using (var session = database.BeginSession())
            {
                var q = new NamedQuery("CustomersViaSP");
                q.Add(new DacParameter("p0", customerNoFrom));
                q.Add(new DacParameter("p1", customerNoTo));
                q.Add(new DacParameter("p2", "The delivery street #544"));

                return(session.Advanced.NamedQuery <Customer>(q).ToArray().Length);
            }
        }
Пример #13
0
        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);
            }
        }
Пример #14
0
        public static void should_have_first_and_last_item_left <T>(this ISisoDatabase db, IList <T> structures) where T : class
        {
            var structureScema = db.StructureSchemas.GetSchema <T>();

            using (var rs = db.BeginSession())
            {
                var items = rs.Query <T>().ToList();

                structureScema.IdAccessor.GetValue(items[0]).Value.ShouldEqual(
                    structureScema.IdAccessor.GetValue(structures[0]).Value);

                structureScema.IdAccessor.GetValue(items[1]).Value.ShouldEqual(
                    structureScema.IdAccessor.GetValue(structures[3]).Value);
            }
        }
Пример #15
0
        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);
            }
        }
Пример #16
0
        public static void should_have_identical_structures <T>(this ISisoDatabase db, params T[] structures) where T : class
        {
            Ensure.That(structures, "structures").HasItems();

            var structureSchema = db.StructureSchemas.GetSchema(typeof(T));

            using (var session = db.BeginSession())
            {
                foreach (var structure in structures)
                {
                    var id        = structureSchema.IdAccessor.GetValue(structure);
                    var refetched = session.GetById <T>(id.Value);
                    refetched.ShouldBeValueEqualTo(structure);
                }
            }
        }
Пример #17
0
        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);
            }
        }
Пример #18
0
 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();
     }
 }
Пример #19
0
 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;
     }
 }
Пример #20
0
 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"));
     }
 }
Пример #21
0
 private static void InsertCustomers(IEnumerable<Customer> customers, ISisoDatabase database)
 {
     using (var unitOfWork = database.BeginSession())
     {
         unitOfWork.InsertMany(customers);
     }
 }
Пример #22
0
 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();
     }
 }
Пример #23
0
 private static int GetAllCustomers(ISisoDatabase database)
 {
     using (var session = database.BeginSession())
     {
         return session.Query<Customer>().ToEnumerable().Count();
     }
 }
Пример #24
0
 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"));
     }
 }
Пример #25
0
        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;
            }
        }
Пример #26
0
 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;
     }
 }
Пример #27
0
        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);
            }
        }
Пример #28
0
 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;
     }
 }
 public virtual ISisoQueryable <T> Query <T>() where T : class
 {
     return(new SisoReadOnceQueryable <T>(
                Db.ProviderFactory.GetQueryBuilder <T>(Db.StructureSchemas),
                () => Db.BeginSession()));
 }