예제 #1
0
        public void CreateTableQuery_ShouldMatch()
        {
            var query = new QueryCommand(TableDef);
            var defs  = query.ColumnDefinitions().ToList();

            Assert.AreEqual(Query.Create, query.Query);
            Assert.IsTrue(query.IfNotExists);

            Assert.AreEqual(new ColumnInfo("task_id", "tasks", typeof(int)), defs[0]);
            Assert.AreEqual(new ColumnInfo("subject", "tasks", typeof(string)), defs[1]);
            Assert.AreEqual(new ColumnInfo("start_date", "tasks", typeof(DateTime)), defs[2]);
            Assert.AreEqual(new ColumnInfo("end_date", "tasks", typeof(DateTime)), defs[3]);
            Assert.AreEqual(new ColumnInfo("description", "tasks", typeof(string)), defs[4]);
        }
예제 #2
0
파일: Bridge.cs 프로젝트: DillonN/CryptoSql
        private async Task <CommandResponse> CreateQuery(QueryCommand qc)
        {
            foreach (var type in Providers.Keys)
            {
                if (!string.IsNullOrWhiteSpace(qc.Database))
                {
                    AssureAddressDictExists(type);
                    if (ConfigManager.Config.DatabaseAddressed[type].ContainsKey(qc.Database))
                    {
                        throw new InvalidOperationException("Cannot create database that already exists!");
                    }

                    await Providers[type].Reset();
                    ConfigManager.Config.DatabaseAddressed[type][qc.Database] = null;
                }
                else if (!string.IsNullOrWhiteSpace(qc.Table))
                {
                    Providers[type].NewTableAsync(qc.Table, qc.ColumnDefinitions());
                }
            }

            return(new CommandResponse(CommandResponseType.OK));
        }