本文整理汇总了C#中Marten.Schema.DocumentMapping.IsHierarchy方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentMapping.IsHierarchy方法的具体用法?C# DocumentMapping.IsHierarchy怎么用?C# DocumentMapping.IsHierarchy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marten.Schema.DocumentMapping
的用法示例。
在下文中一共展示了DocumentMapping.IsHierarchy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpsertFunction
public UpsertFunction(DocumentMapping mapping)
{
if (mapping == null) throw new ArgumentNullException(nameof(mapping));
_functionName = mapping.UpsertFunction;
_tableName = mapping.Table;
_primaryKeyConstraintName = "pk_" + mapping.Table.Name;
var idType = mapping.IdMember.GetMemberType();
var pgIdType = TypeMappings.GetPgType(idType);
Arguments.Add(new UpsertArgument
{
Arg = "docId",
PostgresType = pgIdType,
Column = "id",
Members = new[] {mapping.IdMember}
});
Arguments.Add(new DocJsonBodyArgument());
Arguments.AddRange(mapping.DuplicatedFields.Select(x => x.UpsertArgument));
Arguments.Add(new VersionArgument());
Arguments.Add(new DotNetTypeArgument());
if (mapping.IsHierarchy())
{
Arguments.Add(new DocTypeArgument());
}
if (mapping.UseOptimisticConcurrency)
{
Arguments.Add(new CurrentVersionArgument());
}
}
示例2: GenerateDocumentStorage
public static void GenerateDocumentStorage(DocumentMapping mapping, SourceWriter writer)
{
var upsertFunction = mapping.ToUpsertFunction();
var id_NpgsqlDbType = TypeMappings.ToDbType(mapping.IdMember.GetMemberType());
var typeName = mapping.DocumentType.GetTypeName();
var storeName = _storenameSanitizer.Replace(mapping.DocumentType.GetPrettyName(), string.Empty);
var storageArguments = mapping.ToArguments().ToArray();
var ctorArgs = storageArguments.Select(x => x.ToCtorArgument()).Join(", ");
var ctorLines = storageArguments.Select(x => x.ToCtorLine()).Join("\n");
var fields = storageArguments.Select(x => x.ToFieldDeclaration()).Join("\n");
var baseType = mapping.IsHierarchy() ? "HierarchicalResolver" : "Resolver";
var callBaseCtor = mapping.IsHierarchy() ? $": base({HierarchyArgument.Hierarchy})" : string.Empty;
writer.Write(
[email protected]"
BLOCK:public class {storeName}Storage : {baseType}<{typeName}>, IDocumentStorage, IBulkLoader<{typeName}>, IdAssignment<{typeName}>, IResolver<{typeName}>
{fields}
BLOCK:public {storeName}Storage({ctorArgs}) {callBaseCtor}
{ctorLines}
END
public Type DocumentType => typeof ({typeName});
BLOCK:public NpgsqlCommand UpsertCommand(object document, string json)
return UpsertCommand(({typeName})document, json);
END
BLOCK:public NpgsqlCommand LoaderCommand(object id)
return new NpgsqlCommand(`select {mapping.SelectFields().Join(", ")} from {mapping.QualifiedTableName} as d where id = :id`).With(`id`, id);
END
BLOCK:public NpgsqlCommand DeleteCommandForId(object id)
return new NpgsqlCommand(`delete from {mapping.QualifiedTableName} where id = :id`).With(`id`, id);
END
BLOCK:public NpgsqlCommand DeleteCommandForEntity(object entity)
return DeleteCommandForId((({typeName})entity).{mapping.IdMember.Name});
END
BLOCK:public NpgsqlCommand LoadByArrayCommand<T>(T[] ids)
return new NpgsqlCommand(`select {mapping.SelectFields().Join(", ")} from {mapping.QualifiedTableName} as d where id = ANY(:ids)`).With(`ids`, ids);
END
BLOCK:public void Remove(IIdentityMap map, object entity)
var id = Identity(entity);
map.Remove<{typeName}>(id);
END
BLOCK:public void Delete(IIdentityMap map, object id)
map.Remove<{typeName}>(id);
END
BLOCK:public void Store(IIdentityMap map, object id, object entity)
map.Store<{typeName}>(id, ({typeName})entity);
END
BLOCK:public object Assign({typeName} document, out bool assigned)
{mapping.IdStrategy.AssignmentBodyCode(mapping.IdMember)}
return document.{mapping.IdMember.Name};
END
BLOCK:public object Retrieve({typeName} document)
return document.{mapping.IdMember.Name};
END
public NpgsqlDbType IdType => NpgsqlDbType.{id_NpgsqlDbType};
BLOCK:public object Identity(object document)
return (({typeName})document).{mapping.IdMember.Name};
END
{upsertFunction.ToUpdateBatchMethod(typeName)}
{upsertFunction.ToBulkInsertMethod(typeName)}
END
");
}