本文整理汇总了C#中Schema.GetTableName方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.GetTableName方法的具体用法?C# Schema.GetTableName怎么用?C# Schema.GetTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema.GetTableName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public static void Add(Schema schema)
{
if (CheckTableExists(schema))
{
Delete(schema);
}
StringBuilder columns = new StringBuilder();
schema = schema.AsActual();
foreach (var column in schema.Columns.Where(it => !it.IsSystemField))
{
columns.AppendFormat(",`{0}` {1}", column.Name, ColumnTypeDefinition(column));
}
string ddl = string.Format(createTable, schema.GetTableName(), columns.ToString(), MysqlSettings.Instance.DEFAULT_CHARSET);
ExecuteDDL(schema.Repository, ddl);
}
示例2: CheckTableExists
private static bool CheckTableExists(Schema schema)
{
string sql = string.Format(@"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}'", schema.GetTableName());
MySqlCommand command = new MySqlCommand() { CommandText = sql };
return (long)MysqlHelper.ExecuteScalar(schema.Repository, command) != 0;
}
示例3: Delete
public static void Delete(Schema schema)
{
DropTable(schema.Repository, schema.GetTableName());
}
示例4: ExportSchemaData
public IEnumerable<IDictionary<string, object>> ExportSchemaData(Schema schema)
{
var connectionString = schema.Repository.GetConnectionString();
string sql = string.Format("SELECT * FROM [{0}] ", schema.GetTableName());
List<IDictionary<string, object>> list = new List<IDictionary<string, object>>();
SqlCeConnection connection;
using (var reader = SQLCeHelper.ExecuteReader(connectionString, new SqlCeCommand() { CommandText = sql }, out connection))
{
try
{
while (reader.Read())
{
list.Add(reader.ToContent<TextContent>(new TextContent()));
}
}
finally
{
reader.Close();
connection.Close();
}
}
return list;
}
示例5: Delete
public static void Delete(Schema schema)
{
string ddl = string.Format(dropTable, schema.GetTableName());
ExecuteDDL(schema.Repository, ddl);
}
示例6: CheckTableExists
private static bool CheckTableExists(Schema schema)
{
string sql = string.Format(@"SELECT count(*)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = '{0}' AND TABLE_TYPE='TABLE'", schema.GetTableName());
SqlCeCommand command = new SqlCeCommand() { CommandText = sql };
return (int)SQLCeHelper.ExecuteScalar(schema.Repository.GetConnectionString(), command) != 0;
}
示例7: ExportSchemaData
public IEnumerable<IDictionary<string, object>> ExportSchemaData(Schema schema)
{
string sql = string.Format("SELECT * FROM `{0}` ", schema.GetTableName());
List<TextContent> list = new List<TextContent>();
MySqlConnection connection;
using (var reader = MysqlHelper.ExecuteReader(schema.Repository, new MySqlCommand() { CommandText = sql }, out connection))
{
while (reader.Read())
{
list.Add(reader.ToContent<TextContent>(new TextContent()));
}
connection.Close();
}
return list;
}