本文整理汇总了C#中IStructureSchema.GetStructureTableName方法的典型用法代码示例。如果您正苦于以下问题:C# IStructureSchema.GetStructureTableName方法的具体用法?C# IStructureSchema.GetStructureTableName怎么用?C# IStructureSchema.GetStructureTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStructureSchema
的用法示例。
在下文中一共展示了IStructureSchema.GetStructureTableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetJsonByIds
public override IEnumerable<string> GetJsonByIds(IEnumerable<IStructureId> ids, IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sqlFormat = SqlStatements.GetSql("GetJsonByIds").Inject(structureSchema.GetStructureTableName(), "{0}");
using (var cmd = CreateCommand(string.Empty))
{
foreach (var batchedIds in ids.Batch<IStructureId, IDacParameter>(MaxBatchedIdsSize, (id, batchCount) => new DacParameter(string.Concat("id", batchCount), id.Value)))
{
cmd.Parameters.Clear();
Driver.AddCommandParametersTo(cmd, batchedIds);
var paramsString = string.Join(",", batchedIds.Select(p => p.Name));
cmd.CommandText = sqlFormat.Inject(paramsString);
using (var reader = cmd.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.SequentialAccess))
{
while (reader.Read())
{
yield return reader.GetString(0);
}
reader.Close();
}
}
}
}
示例2: GenerateSql
public string[] GenerateSql(IStructureSchema structureSchema, IndexesTableNames names, IndexesTableStatuses statuses)
{
if(statuses.AllExists)
return new string[0];
var structureTableName = structureSchema.GetStructureTableName();
var sqlTemplateNameSuffix = GetSqlTemplateNameSuffix(structureSchema.IdAccessor.IdType);
var generators = new Func<string>[]
{
() => !statuses.IntegersTableExists
? GenerateSqlFor("CreateIntegersIndexes", sqlTemplateNameSuffix, structureTableName, names.IntegersTableName)
: string.Empty,
() => !statuses.FractalsTableExists
? GenerateSqlFor("CreateFractalsIndexes", sqlTemplateNameSuffix, structureTableName, names.FractalsTableName)
: string.Empty,
() => !statuses.BooleansTableExists
? GenerateSqlFor("CreateBooleansIndexes", sqlTemplateNameSuffix, structureTableName, names.BooleansTableName)
: string.Empty,
() => !statuses.DatesTableExists
? GenerateSqlFor("CreateDatesIndexes", sqlTemplateNameSuffix, structureTableName, names.DatesTableName)
: string.Empty,
() => !statuses.GuidsTableExists
? GenerateSqlFor("CreateGuidsIndexes", sqlTemplateNameSuffix, structureTableName, names.GuidsTableName)
: string.Empty,
() => !statuses.StringsTableExists
? GenerateSqlFor("CreateStringsIndexes", sqlTemplateNameSuffix, structureTableName, names.StringsTableName)
: string.Empty,
() => !statuses.TextsTableExists
? GenerateSqlFor("CreateTextsIndexes", sqlTemplateNameSuffix, structureTableName, names.TextsTableName)
: string.Empty
};
return generators.Select(generator => generator()).Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
}
示例3: GenerateSql
public string GenerateSql(IStructureSchema structureSchema)
{
var sql = structureSchema.IdAccessor.IdType == IdTypes.Guid
? _sqlStrings.GetSql("CreateUniquesGuid")
: _sqlStrings.GetSql("CreateUniquesIdentity");
return sql.Inject(
structureSchema.GetStructureTableName(),
structureSchema.GetUniquesTableName());
}
示例4: DeleteById
public override void DeleteById(IStructureId structureId, IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sql = SqlStatements.GetSql("DeleteById").Inject(structureSchema.GetStructureTableName());
using (var cmd = CreateCommand(sql, new DacParameter("id", structureId.Value)))
{
cmd.ExecuteNonQuery();
}
}
示例5: GenerateSql
public string GenerateSql(IStructureSchema structureSchema)
{
var columnDefinitions = structureSchema.IndexAccessors
.Select(GenerateColumnDefinition);
var columnsString = string.Join(",", columnDefinitions);
var sql = structureSchema.IdAccessor.IdType == IdTypes.Guid
? _sqlStrings.GetSql("CreateIndexesGuid")
: _sqlStrings.GetSql("CreateIndexesIdentity");
return sql.Inject(
structureSchema.GetStructureTableName(),
structureSchema.GetIndexesTableName(),
columnsString);
}
示例6: GenerateSql
public string GenerateSql(IStructureSchema structureSchema)
{
var isValidIdType = structureSchema.IdAccessor.IdType == IdTypes.Guid || structureSchema.IdAccessor.IdType == IdTypes.Identity;
if (!isValidIdType)
throw new NotSupportedException(
ExceptionMessages.DbSchemaUpserter_Upsert_IdTypeNotSupported.Inject(structureSchema.IdAccessor.IdType));
var tableName = structureSchema.GetStructureTableName();
var sql = structureSchema.IdAccessor.IdType == IdTypes.Guid
? _sqlStrings.GetSql("CreateStructuresGuid")
: _sqlStrings.GetSql("CreateStructuresIdentity");
return sql.Inject(tableName);
}
示例7: GenerateSql
public string GenerateSql(IStructureSchema structureSchema)
{
var tableName = structureSchema.GetStructureTableName();
if (structureSchema.IdAccessor.IdType == StructureIdTypes.String)
return _sqlStatements.GetSql("CreateStructuresString").Inject(tableName);
if (structureSchema.IdAccessor.IdType == StructureIdTypes.Guid)
return _sqlStatements.GetSql("CreateStructuresGuid").Inject(tableName);
if (structureSchema.IdAccessor.IdType.IsIdentity())
return _sqlStatements.GetSql("CreateStructuresIdentity").Inject(tableName);
throw new SisoDbException(ExceptionMessages.SqlDbStructureSchemaBuilder_GenerateSql.Inject(structureSchema.IdAccessor.IdType));
}
示例8: Upsert
public void Upsert(IStructureSchema structureSchema)
{
var structuresTableName = structureSchema.GetStructureTableName();
var indexesTableName = structureSchema.GetIndexesTableName();
var uniquesTableName = structureSchema.GetUniquesTableName();
var structuresTableExists = _dbClient.TableExists(structuresTableName);
var indexesTableExists = _dbClient.TableExists(indexesTableName);
var uniquesTableExists = _dbClient.TableExists(uniquesTableName);
if (structuresTableExists && indexesTableExists && uniquesTableExists)
{
_indexesDbSchemaSynchronizer.Synchronize(structureSchema);
_uniquesDbSchemaSynchronizer.Synchronize(structureSchema);
return;
}
var structuresSql = structuresTableExists ? "" : _structuresDbSchemaBuilder.GenerateSql(structureSchema);
var indexesSql = indexesTableExists ? "" : _indexesDbSchemaBuilder.GenerateSql(structureSchema);
var uniquesSql = uniquesTableExists ? "" : _uniquesDbSchemaBuilder.GenerateSql(structureSchema);
using (var cmd = _dbClient.CreateCommand(CommandType.Text, null,
new QueryParameter("entityHash", structureSchema.Hash),
new QueryParameter("entityName", structureSchema.Name)))
{
if (!structuresTableExists)
{
cmd.CommandText = structuresSql;
cmd.ExecuteNonQuery();
}
if (!indexesTableExists)
{
cmd.CommandText = indexesSql;
cmd.ExecuteNonQuery();
}
else
_indexesDbSchemaSynchronizer.Synchronize(structureSchema);
if (!uniquesTableExists)
{
cmd.CommandText = uniquesSql;
cmd.ExecuteNonQuery();
}
else
_uniquesDbSchemaSynchronizer.Synchronize(structureSchema);
}
}
示例9: DeleteByIds
public override void DeleteByIds(IEnumerable<IStructureId> ids, IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sql = SqlStatements.GetSql("DeleteByIds").Inject(structureSchema.GetStructureTableName());
using (var cmd = CreateCommand(sql))
{
foreach (var idBatch in ids.Batch(MaxBatchedIdsSize))
{
cmd.Parameters.Clear();
cmd.Parameters.Add(Sql2008IdsTableParam.CreateIdsTableParam(structureSchema.IdAccessor.IdType, idBatch));
cmd.ExecuteNonQuery();
}
}
}
示例10: DropStructureSet
public void DropStructureSet(IStructureSchema structureSchema)
{
lock (_upsertedSchemas)
{
_upsertedSchemas.Remove(structureSchema.Name);
var sql = _sqlStrings.GetSql("DropStructureTables").Inject(
structureSchema.GetIndexesTableName(),
structureSchema.GetStructureTableName());
using (var client = new SqlDbClient(_connectionInfo, false))
{
client.ExecuteNonQuery(CommandType.Text, sql, new QueryParameter("entityHash", structureSchema.Hash));
}
}
}
示例11: DeleteByIds
public override void DeleteByIds(IEnumerable<IStructureId> ids, IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sqlFormat = SqlStatements.GetSql("DeleteByIds").Inject(structureSchema.GetStructureTableName(), "{0}");
using (var cmd = CreateCommand(string.Empty))
{
foreach (var batchedIds in ids.Batch<IStructureId, IDacParameter>(MaxBatchedIdsSize, (id, batchCount) => new DacParameter(string.Concat("id", batchCount), id.Value)))
{
cmd.Parameters.Clear();
Driver.AddCommandParametersTo(cmd, batchedIds);
var paramsString = string.Join(",", batchedIds.Select(p => p.Name));
cmd.CommandText = sqlFormat.Inject(paramsString);
cmd.ExecuteNonQuery();
}
}
}
示例12: GetJsonByIds
public override IEnumerable<string> GetJsonByIds(IEnumerable<IStructureId> ids, IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sql = SqlStatements.GetSql("GetJsonByIds").Inject(structureSchema.GetStructureTableName());
using (var cmd = CreateCommand(sql))
{
foreach (var idBatch in ids.Batch(MaxBatchedIdsSize))
{
cmd.Parameters.Clear();
cmd.Parameters.Add(SqlServerIdsTableParam.CreateIdsTableParam(structureSchema.IdAccessor.IdType, idBatch));
foreach (var data in YieldJson(structureSchema, cmd))
yield return data;
}
}
}
示例13: Drop
public override void Drop(IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var indexesTableNames = structureSchema.GetIndexesTableNames();
var sql = SqlStatements.GetSql("DropStructureTables").Inject(
indexesTableNames.IntegersTableName,
indexesTableNames.FractalsTableName,
indexesTableNames.BooleansTableName,
indexesTableNames.DatesTableName,
indexesTableNames.GuidsTableName,
indexesTableNames.StringsTableName,
indexesTableNames.TextsTableName,
structureSchema.GetUniquesTableName(),
structureSchema.GetStructureTableName());
using (var cmd = CreateCommand(sql, new DacParameter("entityName", structureSchema.Name)))
{
cmd.ExecuteNonQuery();
}
}
示例14: GetJsonByIds
public override IEnumerable<string> GetJsonByIds(IEnumerable<IStructureId> ids, IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sql = SqlStatements.GetSql("GetJsonByIds").Inject(structureSchema.GetStructureTableName());
using (var cmd = CreateCommand(sql))
{
foreach (var idBatch in ids.Batch(MaxBatchedIdsSize))
{
cmd.Parameters.Clear();
cmd.Parameters.Add(SqlServerIdsTableParam.CreateIdsTableParam(structureSchema.IdAccessor.IdType, idBatch));
using (var reader = cmd.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.SequentialAccess))
{
while (reader.Read())
{
yield return reader.GetString(0);
}
reader.Close();
}
}
}
}
示例15: RowCountByQuery
public override int RowCountByQuery(IStructureSchema structureSchema, DbQuery query)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
var sql = SqlStatements.GetSql("RowCountByQuery").Inject(structureSchema.GetStructureTableName(), query.Sql);
return ExecuteScalar<int>(sql, query.Parameters.ToArray());
}