Пример #1
0
        public void TestManyMore()
        {
            DbEntry.CreateCrossTable(typeof(ManyMoreSqlite), typeof(ManyMore1Sqlite));
            AssertSql(
                @"CREATE TABLE [R_ManyMore_ManyMore1] (
    [ManyMore_Id] BIGINT NOT NULL ,
    [ManyMore1_Id] BIGINT NOT NULL ,
    FOREIGN KEY([ManyMore_Id]) REFERENCES [ManyMore] ([Id]) ,
    FOREIGN KEY([ManyMore1_Id]) REFERENCES [ManyMore1] ([Id]) 
);
CREATE INDEX [IX_R_ManyMore_ManyMore1_ManyMore_Id] ON [R_ManyMore_ManyMore1] ([ManyMore_Id] ASC);
CREATE INDEX [IX_R_ManyMore_ManyMore1_ManyMore1_Id] ON [R_ManyMore_ManyMore1] ([ManyMore1_Id] ASC);
<Text><30>()");

            DbEntry.CreateCrossTable(typeof(ManyMoreSqlite), typeof(ManyMore2Sqlite));
            AssertSql(
                @"CREATE TABLE [R_ManyMore_ManyMore2] (
    [ManyMore_Id] BIGINT NOT NULL ,
    [ManyMore2_Id] BIGINT NOT NULL ,
    FOREIGN KEY([ManyMore_Id]) REFERENCES [ManyMore] ([Id]) ,
    FOREIGN KEY([ManyMore2_Id]) REFERENCES [ManyMore2] ([Id]) 
);
CREATE INDEX [IX_R_ManyMore_ManyMore2_ManyMore_Id] ON [R_ManyMore_ManyMore2] ([ManyMore_Id] ASC);
CREATE INDEX [IX_R_ManyMore_ManyMore2_ManyMore2_Id] ON [R_ManyMore_ManyMore2] ([ManyMore2_Id] ASC);
<Text><30>()");
        }
Пример #2
0
        public void Test11()
        {
            DbEntry.CreateCrossTable(typeof(ReaderSqlite), typeof(ArticleSqlite));
            Assert.AreEqual(1, StaticRecorder.Messages.Count);
            AssertSql(0,
                      @"CREATE TABLE [R_Article_Reader] (
    [Article_Id] BIGINT NOT NULL ,
    [Reader_Id] BIGINT NOT NULL ,
    FOREIGN KEY([Article_Id]) REFERENCES [Article] ([Id]) ,
    FOREIGN KEY([Reader_Id]) REFERENCES [Reader] ([Id]) 
);
CREATE INDEX [IX_R_Article_Reader_Article_Id] ON [R_Article_Reader] ([Article_Id] ASC);
CREATE INDEX [IX_R_Article_Reader_Reader_Id] ON [R_Article_Reader] ([Reader_Id] ASC);
<Text><30>()");
        }
Пример #3
0
        public void Test10()
        {
            DbEntry.DropAndCreate(typeof(TableC));
            DbEntry.DropAndCreate(typeof(TableD));
            DbEntry.CreateCrossTable(typeof(TableC), typeof(TableD));

            var t1 = new TableC {
                Title = "Article1"
            };

            t1.Save();

            var t3 = new TableD {
                Name = "Tag1"
            };

            t3.Save();

            var t2 = TableC.FindOne(p => p.Id == 1);

            t2.TD.Add(t3);
            t2.Save();

            //Begin Remove

            var t4 = TableC.FindById(1);

            Assert.AreEqual(1, t4.TD.Count);
            var t5 = TableD.FindById(1);

            Assert.AreEqual(1, t5.TC.Count);

            bool b = t4.TD.Remove(t5);

            Assert.IsTrue(b);
            t4.Save();

            //here b= false and can't trace the delete sql

            bool b2 = t5.TC.Remove(t4);

            Assert.IsTrue(b2);
            t5.Save();

            //here b2= false and can't trace the delete sql
        }
Пример #4
0
        public void TestDefineCrossTableName2()
        {
            DbEntry.Create(typeof(crxBook1Sqlite));
            AssertSql(
                @"CREATE TABLE [crx_Book1Sqlite] (
    [Id] INTEGER PRIMARY KEY AUTOINCREMENT ,
    [Name] NVARCHAR (20) NOT NULL 
);
<Text><30>()");

            DbEntry.CreateCrossTable(typeof(crxBook1Sqlite), typeof(crxCategory1Sqlite));
            AssertSql(
                @"CREATE TABLE [R_book_and_category] (
    [crxBook1Sqlite_Id] BIGINT NOT NULL ,
    [crxCategory1Sqlite_Id] BIGINT NOT NULL ,
    FOREIGN KEY([crxBook1Sqlite_Id]) REFERENCES [crx_Book1Sqlite] ([Id]) ,
    FOREIGN KEY([crxCategory1Sqlite_Id]) REFERENCES [crx_Category1Sqlite] ([Id]) 
);
CREATE INDEX [IX_R_book_and_category_crxBook1Sqlite_Id] ON [R_book_and_category] ([crxBook1Sqlite_Id] ASC);
CREATE INDEX [IX_R_book_and_category_crxCategory1Sqlite_Id] ON [R_book_and_category] ([crxCategory1Sqlite_Id] ASC);
<Text><30>()");
        }