示例#1
0
文件: SqlBox.cs 项目: built/BoxBoy
        public bool createStream(Item item)
        {
            SqlBoxQuery query = new SqlBoxQuery();

            if (item.UsesAutoId)
            {
                query.Append("CREATE TABLE %table%(%pk% int IDENTITY(1,1) PRIMARY KEY CLUSTERED%fields%)");
            }
            else
            {
                query.Append("CREATE TABLE %table%(%pk% int PRIMARY KEY CLUSTERED%fields%)");
            }
            string       val    = ", %name% varchar(255) DEFAULT NULL";
            string       strA   = item.getIdField();
            StringTheory theory = new StringTheory();

            foreach (string str3 in item.getBoxView().Keys)
            {
                if (string.Compare(strA, str3, true) != 0)
                {
                    theory.Append(val);
                    theory.Replace("%name%", str3);
                }
            }
            query.Replace("%table%", item.getStreamName());
            query.Replace("%pk%", strA);
            query.Replace("%fields%", theory);
            Console.WriteLine(query);
            this.SqlDatabase.process(query);
            return(this.streamExists(item));
        }
示例#2
0
文件: SqlBox.cs 项目: built/BoxBoy
        public bool deleteStream(Item item)
        {
            SqlBoxQuery query = new SqlBoxQuery();

            query.Append("drop table " + item.getStreamName());
            this.SqlDatabase.process(query);
            return(!this.streamExists(item));
        }
示例#3
0
文件: SqlBox.cs 项目: built/BoxBoy
        public bool streamExists(string streamName)
        {
            ArrayList   results = new ArrayList();
            SqlBoxQuery query   = new SqlBoxQuery();

            query.Append("SELECT * FROM information_schema.tables WHERE TABLE_NAME = '%StreamName%'");
            query.Replace("%StreamName%", streamName);
            this.SqlDatabase.process(query, results);
            return(results.Count > 0);
        }