Ejemplo n.º 1
0
 public void AddFieldByString()
 {
     var provider = new SqliteContextProvider(ConnectionString);
     var logger = new MessageStackLogger();
     provider.Settings.AddLogger(logger);
     using (var context = provider.Open())
     {
         context.Database.Table<Warrior>().Ignore(wrir => wrir.Race).Create();
         context.Database.Table<Warrior>().Column("Race", FieldOperation.Add, typeof(string)).Alter();
         context.Commit();
     }
 }
Ejemplo n.º 2
0
        public void CreateTableNotNullableColumn()
        {
            CreateDatabaseIfNotExists();

            var provider = new SqlContextProvider(GetConnectionString("WarriorDB"));
            var logger = new MessageStackLogger();
            provider.Settings.AddLogger(logger);
            using (var context = provider.Open())
            {
                // table with a foreign key
                context.Database.Table<Warrior>()
                    .Column(wrir => wrir.ID, isNullable: false)
                    .Column(wrir => wrir.Race, isNullable: false)
                    .Create();

                context.Commit();

                Assert.AreEqual(logger.Logs.First().Message.Flatten(), "CREATE TABLE Warrior (ID int NOT NULL, Race varchar(max) NOT NULL, Name varchar(max), WeaponID int NOT NULL, SpecialSkill varchar(max))");
            }
        }
Ejemplo n.º 3
0
        public void CreateTableNotNullableColumn()
        {
            var provider = new SqliteContextProvider(ConnectionString);
            var logger = new MessageStackLogger();
            provider.Settings.AddLogger(logger);
            using (var context = provider.Open())
            {
                // table with a foreign key
                context.Database.Table<Warrior>()
                    .Column(wrir => wrir.ID)
                    .Column(wrir => wrir.Race, isNullable: false)
                    .Create();

                Assert.IsFalse(File.Exists(DatabaseName));

                //context.QueryCommandStore.First().Execute(context);

                context.Commit();

                Assert.AreEqual(logger.Logs.First().Message.Flatten(), "CREATE TABLE IF NOT EXISTS Warrior (ID int NOT NULL, Race varchar(1000) NOT NULL, Name varchar(1000), WeaponID int NOT NULL, SpecialSkill varchar(1000))");
            }
        }