コード例 #1
0
        public void SqlServerSchemaShouldBeGeneratedAndUsable() {
            var recordDescriptors = new[] {
                                              new RecordBlueprint {TableName = "Hello", Type = typeof (FooRecord)}
                                          };

            ProviderUtilities.RunWithSqlServer(recordDescriptors,
                sessionFactory => {
                    var session = sessionFactory.OpenSession();
                    var foo = new FooRecord { Name = "hi there" };
                    session.Save(foo);
                    session.Flush();
                    session.Close();

                    Assert.That(foo, Is.Not.EqualTo(0));

                });
        }
コード例 #2
0
ファイル: FluentDbTests.cs プロジェクト: Vinna/DeepInSummer
        public void UsingDataUtilityToBuildSessionFactory() {
            var factory = DataUtility.CreateSessionFactory(typeof(FooRecord), typeof(BarRecord));

            var session = factory.OpenSession();
            var foo1 = new FooRecord { Name = "world" };
            session.Save(foo1);
            session.Close();

            session = factory.OpenSession();
            var foo2 = session.CreateCriteria<FooRecord>()
                .Add(Restrictions.Eq("Name", "world"))
                .List<FooRecord>().Single();
            session.Close();

            Assert.That(foo1, Is.Not.SameAs(foo2));
            Assert.That(foo1.Id, Is.EqualTo(foo2.Id));
        }
コード例 #3
0
        public void SQLiteSchemaShouldBeGeneratedAndUsable() {
            var recordDescriptors = new[] {
                                              new RecordTopology {TableName = "Hello", Type = typeof (FooRecord)}
                                          };
            var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
            var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
                                                                                              Provider = "SQLite",
                                                                                              DataFolder = _tempDataFolder,
                                                                                              UpdateSchema = true,
                                                                                              RecordDescriptors = recordDescriptors
                                                                                          });


            var session = sessionFactory.OpenSession();
            var foo = new FooRecord { Name = "hi there" };
            session.Save(foo);
            session.Flush();
            session.Close();

            Assert.That(foo, Is.Not.EqualTo(0));

            sessionFactory.Close();

        }
コード例 #4
0
ファイル: RepositoryTests.cs プロジェクト: wezmag/Coevery
        public void RepositoryCanCreateFetchAndDelete() {
            var foo1 = new FooRecord { Name = "yadda" };
            _fooRepos.Create(foo1);

            var foo2 = _fooRepos.Get(foo1.Id);
            foo2.Name = "blah";            

            Assert.That(foo1, Is.SameAs(foo2));

            _fooRepos.Delete(foo2);
        }
コード例 #5
0
        public void SqlServerSchemaShouldBeGeneratedAndUsable() {
            var databasePath = Path.Combine(_tempDataFolder, "Orchard.mdf");
            CreateSqlServerDatabase(databasePath);

            var recordDescriptors = new[] {
                                              new RecordTopology {TableName = "Hello", Type = typeof (FooRecord)}
                                          };

            var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
            var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
                                                                                              Provider = "SqlServer",
                                                                                              DataFolder = _tempDataFolder,
                                                                                              ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFileName=" + databasePath + ";Integrated Security=True;User Instance=True;",
                                                                                              UpdateSchema = true,
                                                                                              RecordDescriptors = recordDescriptors,
                                                                                          });



            var session = sessionFactory.OpenSession();
            var foo = new FooRecord { Name = "hi there" };
            session.Save(foo);
            session.Flush();
            session.Close();

            Assert.That(foo, Is.Not.EqualTo(0));

            sessionFactory.Close();
        }