Beispiel #1
0
        private static void CreateNodes()
        {
            using (var unitOfWork = new UnitOfWork())
            {
                var repository = new NodeRepository(unitOfWork);

                for (int i = 0; i < NumberOfNodes; i++)
                {
                    var node = new Node("Node " + (i + 1));
                    repository.Save(node);
                }

                unitOfWork.Commit();
            }

            using (var unitOfWork = new UnitOfWork())
            {
                var repository = new MongoNodeRepository(unitOfWork);

                for (int i = 0; i < NumberOfNodes; i++)
                {
                    var node = new MongoNode("Node " + (i + 1));
                    repository.Save(node);
                }

                unitOfWork.Commit();
            }
        }
Beispiel #2
0
        private static long FetchMongoNodes()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            for (int i = 0; i < NumberOfNodes; i++)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    var repository = new MongoNodeRepository(unitOfWork);

                    MongoNode node = repository.GetById(i + 1);
                    IReadOnlyList<NodeLink> links = node.Links;
                }
            }

            stopwatch.Stop();
            return stopwatch.ElapsedMilliseconds;
        }
Beispiel #3
0
        private static long LinkMongoNodes()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            using (var unitOfWork = new UnitOfWork())
            {
                var repository = new MongoNodeRepository(unitOfWork);

                IList<MongoNode> nodes = repository.GetAll();
                foreach (MongoNode node1 in nodes)
                {
                    foreach (MongoNode node2 in nodes)
                    {
                        node1.AddLink(node2);
                    }
                }

                unitOfWork.Commit();
            }

            stopwatch.Stop();
            return stopwatch.ElapsedMilliseconds;
        }