本文整理汇总了C#中IStructureSchema类的典型用法代码示例。如果您正苦于以下问题:C# IStructureSchema类的具体用法?C# IStructureSchema怎么用?C# IStructureSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStructureSchema类属于命名空间,在下文中一共展示了IStructureSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SchemaIsAllreadyUpserted
private bool SchemaIsAllreadyUpserted(IStructureSchema structureSchema, IDbClient dbClient)
{
if (UpsertedSchemas.Contains(structureSchema.Name) || TransientSchemas.Contains(structureSchema.Name))
return true;
return (UpsertedSchemasByDbClient.ContainsKey(dbClient.Id) && UpsertedSchemasByDbClient[dbClient.Id].Contains(structureSchema.Name));
}
示例2: Synchronize
public void Synchronize(IStructureSchema structureSchema)
{
var keyNamesToDrop = GetKeyNamesToDrop(structureSchema);
if (keyNamesToDrop.Count > 0)
DeleteRecordsMatchingKeyNames(structureSchema, keyNamesToDrop);
}
示例3: 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();
}
示例4: 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();
}
}
}
}
示例5: CreateForInserts
private IStructureBuilder CreateForInserts(IStructureSchema structureSchema, IIdentityStructureIdGenerator identityStructureIdGenerator)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
Ensure.That(identityStructureIdGenerator, "identityStructureIdGenerator").IsNotNull();
var idType = structureSchema.IdAccessor.IdType;
if (idType == StructureIdTypes.Guid)
return new StructureBuilder
{
StructureIdGenerator = new SequentialGuidStructureIdGenerator(),
StructureSerializer = new SerializerForStructureBuilder()
};
if (idType.IsIdentity())
return new StructureBuilder
{
StructureIdGenerator = identityStructureIdGenerator,
StructureSerializer = new SerializerForStructureBuilder()
};
if (idType == StructureIdTypes.String)
return new StructureBuilderPreservingId
{
StructureIdGenerator = new EmptyStructureIdGenerator(),
StructureSerializer = new SerializerForStructureBuilder()
};
throw new SisoDbException(ExceptionMessages.StructureBuilders_CreateForInsert.Inject(idType, structureSchema.Name));
}
示例6: CheckOutAndGetSeed
public int CheckOutAndGetSeed(IStructureSchema structureSchema, int numOfIds)
{
using(var dbClient = new SqlDbClient(_connectionInfo, false))
{
return dbClient.GetIdentity(structureSchema.Hash, numOfIds);
}
}
示例7: Generate
public IStructureId[] Generate(IStructureSchema structureSchema, int numOfIds)
{
if (structureSchema.IdAccessor.IdType == StructureIdTypes.Identity)
return GenerateIdentityStructureId(structureSchema, numOfIds);
return GenerateBigIdentityStructureId(structureSchema, numOfIds);
}
示例8: GetDbKeyNamesToDrop
private string[] GetDbKeyNamesToDrop(IStructureSchema structureSchema, IDbClient dbClient)
{
var structureFields = new HashSet<string>(structureSchema.IndexAccessors.Select(iac => iac.Path));
var keyNames = GetExistingDbKeyNames(structureSchema, dbClient);
return keyNames.Where(kn => !structureFields.Contains(kn)).ToArray();
}
示例9: RemoveFromCache
public virtual void RemoveFromCache(IStructureSchema structureSchema)
{
lock (_upsertedSchemas)
{
_upsertedSchemas.Remove(structureSchema.Name);
}
}
示例10: Insert
public virtual void Insert(IStructureSchema structureSchema, IStructure[] structures)
{
var groupedIndexInsertActions = new IndexInsertAction[0];
Task task = null;
try
{
task = Task.Factory.StartNew(
() => groupedIndexInsertActions = CreateGroupedIndexInsertActions(structureSchema, structures));
InsertStructures(structureSchema, structures);
InsertUniques(structureSchema, structures);
Task.WaitAll(task);
}
finally
{
if (task != null && task.Status == TaskStatus.RanToCompletion)
task.Dispose();
}
if (!groupedIndexInsertActions.Any())
return;
InsertIndexes(groupedIndexInsertActions);
}
示例11: Synchronize
public void Synchronize(IStructureSchema structureSchema, IDbClient dbClient)
{
var keyNamesToDrop = GetDbKeyNamesToDrop(structureSchema, dbClient);
if (keyNamesToDrop.Any())
DeleteRecordsMatchingKeyNames(structureSchema, keyNamesToDrop, dbClient);
}
示例12: Query
public Query(IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
StructureSchema = structureSchema;
IsCacheable = false;
}
示例13: GetDefaultBuilderForInserts
public static IStructureBuilder GetDefaultBuilderForInserts(IStructureBuilders builders, IStructureSchema schema, IDbClient dbClient)
{
Ensure.That(builders, "builders").IsNotNull();
Ensure.That(schema, "schema").IsNotNull();
Ensure.That(dbClient, "dbClient").IsNotNull();
var idType = schema.IdAccessor.IdType;
if (idType.IsGuid())
return new StructureBuilder
{
StructureIdGenerator = builders.GuidStructureIdGeneratorFn(schema),
StructureSerializer = builders.StructureSerializerFn()
};
if (idType.IsIdentity())
return new StructureBuilder
{
StructureIdGenerator = builders.IdentityStructureIdGeneratorFn(schema, dbClient),
StructureSerializer = builders.StructureSerializerFn()
};
if (idType.IsString())
return new StructureBuilderPreservingId
{
StructureIdGenerator = new EmptyStructureIdGenerator(),
StructureSerializer = builders.StructureSerializerFn()
};
throw new SisoDbException(ExceptionMessages.StructureBuilders_CreateForInsert.Inject(idType, schema.Name));
}
示例14: GetKeyNamesToDrop
private IList<string> GetKeyNamesToDrop(IStructureSchema structureSchema)
{
var structureFields = new HashSet<string>(structureSchema.IndexAccessors.Select(iac => iac.Name));
var keyNames = GetKeyNames(structureSchema);
return keyNames.Where(kn => !structureFields.Contains(kn)).ToList();
}
示例15: Query
public Query(IStructureSchema structureSchema)
{
Ensure.That(structureSchema, "structureSchema").IsNotNull();
StructureSchema = structureSchema;
Includes = new List<IParsedLambda>();
}