当前位置: 首页>>代码示例>>C#>>正文


C# DocumentMapping.ToArguments方法代码示例

本文整理汇总了C#中Marten.Schema.DocumentMapping.ToArguments方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentMapping.ToArguments方法的具体用法?C# DocumentMapping.ToArguments怎么用?C# DocumentMapping.ToArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Marten.Schema.DocumentMapping的用法示例。


在下文中一共展示了DocumentMapping.ToArguments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildStorageObject

        public static IDocumentStorage BuildStorageObject(IDocumentSchema schema, Type storageType, DocumentMapping mapping)
        {
            var arguments = mapping.ToArguments().Select(arg => arg.GetValue(schema)).ToArray();

            var ctor = storageType.GetConstructors().Single();

            return ctor.Invoke(arguments).As<IDocumentStorage>();
        }
开发者ID:nieve,项目名称:marten,代码行数:8,代码来源:DocumentStorageBuilder.cs

示例2: storage_arguments_adds_hierarchy_argument_with_subclasses

        public void storage_arguments_adds_hierarchy_argument_with_subclasses()
        {
            var mapping = new DocumentMapping(typeof(Squad), new StoreOptions());
            mapping.AddSubClass(typeof(FootballTeam));

            mapping.ToArguments().OfType<HierarchyArgument>()
                .Single().Mapping.ShouldBeSameAs(mapping);
        }
开发者ID:jimbono,项目名称:marten,代码行数:8,代码来源:DocumentMappingTests.cs

示例3: 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

");
        }
开发者ID:nieve,项目名称:marten,代码行数:88,代码来源:DocumentStorageBuilder.cs


注:本文中的Marten.Schema.DocumentMapping.ToArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。