TShock/TShockAPI/DB/IQueryCreator.cs
2011-08-03 02:55:12 -04:00

28 lines
849 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TShockAPI.DB
{
public interface IQueryCreator
{
string CreateTable(SqlTable table);
}
public class SqliteQueryCreator : IQueryCreator
{
public string CreateTable(SqlTable table)
{
var columns = table.Columns.Select(c => "'{0}' {1} {2} {3} {4}".SFormat(c.Name, c.Type, c.Primary ? "PRIMARY KEY" : "", c.AutoIncrement ? "AUTOINCREMENT" : "", c.NotNull ? "NOT NULL" : "", c.Unique ? "UNIQUE" : ""));
return "CREATE TABLE '{0}' ({1})".SFormat(table.Name, string.Join(", ", columns));
}
}
public class MysqlQueryCreator : IQueryCreator
{
public string CreateTable(SqlTable table)
{
throw new NotImplementedException();
}
}
}