예제 #1
0
        public void Test4()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            //var wheelCube = new WheelCube { Code = "3" };
            //var st = session.Save(wheelCube);


            //session.Clear();
            //session.Dispose();
            //session = connection.GetSessionFactory().OpenSession();
            //var ss = session.QueryOver<WheelCube>().List();



            return;


            var certificate = session.Query <Certificate>().Fetch(x => x.Group).ThenFetch(x => x.Students).ToList().First();

            session.Dispose();

            certificate.Group.Students.Clear();
            //var student = new Student { Name = "the new maratoss", Group = certificate.Group };
            //certificate.Group.Students.Add(student);

            session = connection.GetSessionFactory().OpenSession();
            session.Update(certificate);
            session.Flush();

            session.Dispose();
        }
예제 #2
0
        public void Test2()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            var planCertificate =
                session.Query <PlanCertificate>()
                .Fetch(x => x.CertificateQuality)
                .Where(x => x.Rn == 1008161275L).ToList().First();

            var dto = planCertificate.MapTo <PlanCertificateDto>();

            planCertificate = dto.MapTo <PlanCertificate>();

            session.Clear();
            session.Dispose();

            session = connection.GetSessionFactory().OpenSession();

            ITransaction tr = session.BeginTransaction();

            var repository = new RepositoryFactory(session).Create <PlanCertificate>();
            var attachDoc  = new CertificateQualityAttachedDocument
            {
                BData = new byte[] { 1, 2, 3 },
                AttachedDocumentType = new AttachedDocumentType {
                    Rn = 760351674
                },
                Document = 437790479,
                Note     = "ololo",
                // UnitCode = "QUALITY_CERTIFICATE",
                Catalog = new Catalog(465000873)
            };

            planCertificate.CertificateQuality.AttachedDocuments.Add(attachDoc);

            string cqGuid = Guid.NewGuid().ToString();
            string pcGuid = Guid.NewGuid().ToString();

            planCertificate.CertificateQuality.Note = cqGuid;
            planCertificate.Note = pcGuid;

            var pc = session.Merge(planCertificate);
            var cq = session.Merge(planCertificate.CertificateQuality);

            session.Update(pc);
            session.Update(cq);

            tr.Commit();
            tr.Dispose();
            session.Dispose();
        }
예제 #3
0
        public void Test()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            var cert = session.Query <Certificate>()
                       .Fetch(x => x.Group)
                       .ThenFetch(x => x.Students)
                       .First();

            cert.Group.Students[0].TermPapers.DoForEach(x => { });

            session.Clear();
            session.Dispose();

            session = connection.GetSessionFactory().OpenSession();

            ITransaction transaction = session.BeginTransaction();

            var paper = new TermPaper {
                Name = "ALALA", Student = cert.Group.Students[0]
            };

            cert.Group.Students[0].TermPapers.Add(paper);

            var group = session.Merge(cert.Group);

            session.Update(group);
            session.Update(group.Certificate);

            transaction.Commit();
            transaction.Dispose();
            session.Dispose();
            return;


            var certificate = session.Query <Certificate>().Fetch(x => x.Group).ThenFetch(x => x.Students).ToList().First();

            session.Dispose();

            certificate.Group.Students.Clear();
            //var student = new Student { Name = "the new maratoss", Group = certificate.Group };
            //certificate.Group.Students.Add(student);

            session = connection.GetSessionFactory().OpenSession();
            session.Update(certificate);
            session.Flush();

            session.Dispose();
        }
예제 #4
0
        public void Test9()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            var user = new User {
                Name = "maratoss"
            };
            var user_2 = new User {
                Name = "maratoss 2"
            };

            using (ITransaction tr = session.BeginTransaction())
            {
                session.Save(user);
                session.Save(user_2);
                tr.Commit();
            }

            using (ITransaction tr = session.BeginTransaction())
            {
                session.Delete(user);
                session.Delete(user_2);
                tr.Commit();
            }
        }
예제 #5
0
        public void Test6()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            var cq  = session.Get <PlanReceiptOrder>(1008067627L);
            var dto = cq.MapTo <PlanReceiptOrderDto>();

            session.Dispose();
            session = connection.GetSessionFactory().OpenSession();

            cq = session.Get <PlanReceiptOrder>(1008067627L);
            var dto2s = cq.MapTo <PlanReceiptOrderWithoutPlanCertificateDto>();
        }
예제 #6
0
        public void Test10()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting("112BAITULLIN", "1", "dupparus");
            ISession session = connection.GetSessionFactory().OpenSession();

            var pm = new UI.Entities.PermissionMaterialDomain.PermissionMaterial {
                Rn = 1008338040
            };

            var pmDto    = pm.MapTo <PermissionMaterialDto>();
            var pmClient = pmDto.MapTo <UI.Entities.PermissionMaterialDomain.PermissionMaterial>();

            session.Dispose();



            var pmEx = new UI.Entities.PermissionMaterialDomain.PermissionMaterialExtension {
                PermissionMaterial = pmClient
            };

            pmEx.AcceptToDate = new DateTime(2013, 05, 05);
            var user = new UI.Entities.PermissionMaterialDomain.PermissionMaterialExtensionUser
            {
                RnUser = 484082568L,
                PermissionMaterialExtension = pmEx,
                Fullname      = "fullname",
                UserPsdepName = "UserPsdepName",
                UserDept      = "123",
            };

            pmEx.PmeUsers.Add(user);

            var pmeDto = pmEx.MapTo <PermissionMaterialExtensionDto>();
            var srvPM  = pmeDto.MapTo <ParusModel.Entities.PermissionMaterialDomain.PermissionMaterialExtension>();


            session = connection.GetSessionFactory().OpenSession();
            session.Save(srvPM);
            session.Flush();
        }
예제 #7
0
        public void Test5()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            var doc = new AttachedDocument
            {
                AttachedDocumentType = new AttachedDocumentType {
                    Rn = 813609324
                },
                BData    = new byte[] { 1, 2, 3 },
                Code     = "Code",
                Catalog  = new Catalog(465000873),
                Document = 437790479,
                Note     = "1",
                //  UnitCode = "Contracts"
            };

            session.Save(doc);

            return;
            //            var planCertificate =
            //                session.Query<PlanCertificate>()
            //                    .Fetch(x => x.CertificateQuality)
            //                    .ThenFetchMany(x => x.ChemicalIndicatorValues)
            //                    .Where(x => x.Rn == 1008028460L).ToList().First();
            //
            //            var dto = planCertificate.MapTo<PlanCertificateDto>();
            //            planCertificate = dto.MapTo<PlanCertificate>();
            //
            //            session.Clear();
            //            session.Dispose();
            //
            //
            //            session = connection.GetSessionFactory().OpenSession();
            //
            //            planCertificate.Rn = 0;
            //            planCertificate.CertificateQuality.Rn = 0;
            //
            //
            //            planCertificate.CertificateQuality.AttachedDocuments.Add(doc);
            //
            //
            //            var repository = new RepositoryFactory(session).Create<PlanCertificate>();
            //            repository.Insert(planCertificate);
            //
            //            session.Flush();
            //            session.Dispose();
        }
예제 #8
0
        public void Test11()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession     session = connection.GetSessionFactory().OpenSession();
            ITransaction tr      = session.BeginTransaction();

            var user = new User {
                Name = "ALALALLA"
            };

            session.Save(user);
        }
예제 #9
0
        public void Test3()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession     session     = connection.GetSessionFactory().OpenSession();
            ITransaction transaction = session.BeginTransaction();

            TestData.ActSelectionOfProbeGenerator(session);

            transaction.Commit();
            transaction.Dispose();
            session.Dispose();
        }
예제 #10
0
        public void ConnectToDb()
        {
            INhConnection connection = new NhConnection();

            connection.Connecting("parus", "q", "dupparus");

            using (ISessionFactory sessionFactory = connection.GetSessionFactory())
                using (ISession session = sessionFactory.OpenSession())
                {
                    var login = session.CreateSQLQuery("select user from dual")
                                .UniqueResult <string>();

                    Assert.That(login, Is.EqualTo("parus").IgnoreCase);
                }
        }
예제 #11
0
        public void t()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            var cq  = session.QueryOver <CertificateQuality>().Where(x => x.Rn == 1008334353L).UnderlyingCriteria.UniqueResult <CertificateQuality>();
            var map = cq.MapTo <CertificateQualityDto>();


            var usDto =
                map.MapTo <UI.Entities.CertificateQualityDomain.ManufacturersCertificateDomain.CertificateQuality>();

            var us =
                usDto.MapTo <CertificateQualityDto>();

            us = us;
        }
예제 #12
0
        public void Test2()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();

            //IQuery Q = session.GetNamedQuery("Get_Links")
            //    //.SetResultTransformer(new ToListResultTransformer());
            //    //session.CreateSQLQuery("").ad
            //   .SetParameter("RN", 253655604)
            //    .SetParameter("Direction", DirectionFind.Forward);

            // IQuery Q = session.CreateSQLQuery("   select PKG_UDO_UTIL.F_GetLinks()1 as ret from dual ").AddEntity(typeof(LinkDto));
            //typeof(LinkDto);
            var sp     = new GetLinks(253655604, DirectionFind.Backward);
            var Q      = session.ExecuteSp(sp);
            var result = Q.List();


            //var query = MockRepository.GenerateMock<IQueryOver<LinkDto, LinkDto>>();
            //query.Stub(x => x.List<LinkDto>()).Return();
        }
예제 #13
0
        public void Test8()
        {
            var connection = new NhConnection("hibernate.cfg.xml");

            connection.Connecting();
            ISession session = connection.GetSessionFactory().OpenSession();
            // CreditSlip creditSlip = SampleEntity.CreateCreditSlip();

            var creditSlip =
                session.QueryOver <CreditSlip>()
                .Where(x => x.State == CreditSlipState.NotFulfilled)
                .Take(1)
                .UnderlyingCriteria.UniqueResult <CreditSlip>();

            CreditSlipSpecification creditSlipSpec_1 = SampleEntity.CreateCreditSlipSpecification(creditSlip, session);
            CreditSlipSpecification creditSlipSpec_2 = SampleEntity.CreateCreditSlipSpecification(creditSlip, session);

            creditSlipSpec_1.SerNumb = "new ser numb qqq";
            creditSlipSpec_2.SerNumb = "new ser numb zzz 2";

            creditSlip.CreditSlipSpecifications.Add(creditSlipSpec_1);
            creditSlip.CreditSlipSpecifications.Add(creditSlipSpec_2);

            using (ITransaction tr = session.BeginTransaction())
            {
                session.Save(creditSlipSpec_1);
                tr.Commit();
            }

            using (ITransaction tr = session.BeginTransaction())
            {
                session.Delete(creditSlipSpec_1);
                session.Delete(creditSlipSpec_2);
                tr.Commit();
            }
        }