Exemplo n.º 1
0
        public int CreateTable(string tableName, params SQLiteFieldAffinity[] fieldAffinities)
        {
            StringBuilder cmdBuilder = new StringBuilder();

            cmdBuilder.Append("CREATE TABLE ");
            cmdBuilder.Append(tableName);
            cmdBuilder.Append(" (");
            for (int i = 0; i < fieldAffinities.Length; ++i)
            {
                SQLiteFieldAffinity fieldAffinity = fieldAffinities[i];

                cmdBuilder.Append($"{fieldAffinity.columnName} {fieldAffinity.type}");
                if (i < fieldAffinities.Length - 1)
                {
                    cmdBuilder.Append(",");
                }
            }
            cmdBuilder.Append(");");

            return(ExecuteNonQuery(cmdBuilder.ToString()));
        }
Exemplo n.º 2
0
        public int CreateColumn(string tableName, SQLiteFieldAffinity memberInfo)
        {
            string cmdText = $"ALTER TABLE {tableName} ADD COLUMN {memberInfo.columnName} {memberInfo.type.ToString()};";

            return(ExecuteNonQuery(cmdText));
        }