Пример #1
0
    static string ReadOrCreate(PartitionPlan partitionPlan, DocumentPlan documentPlan) => $@"
    /// <summary>
    /// Read a {documentPlan.ClassName} document, or create it if it does not yet exist.
    /// .id must be set if there is no stable id generator defined
    /// .pk, .CreationDate and .Type are set automatically
    /// </summary>
    /// <exception cref=""Cosmogenesis.Core.DbOverloadedException"" />
    /// <exception cref=""Cosmogenesis.Core.DbUnknownStatusCodeException"" />
    internal protected virtual System.Threading.Tasks.Task<Cosmogenesis.Core.ReadOrCreateResult<{documentPlan.FullTypeName}>> ReadOrCreateAsync(bool tryCreateFirst, {documentPlan.FullTypeName} {documentPlan.ClassNameArgument})
    {{
        {DocumentModelWriter.CreateAndCheckPkAndId(partitionPlan, documentPlan, documentPlan.ClassNameArgument)}
        return this.ReadOrCreateItemAsync(item: {documentPlan.ClassNameArgument}, type: {documentPlan.ConstDocType}, tryCreateFirst: tryCreateFirst);
    }}
";
Пример #2
0
    static string CreateOrReplace(PartitionPlan partitionPlan, DocumentPlan documentPlan) =>
    !documentPlan.IsMutable && !documentPlan.IsTransient
        ? ""
        : $@"
    /// <summary>
    /// Create or replace (unconditionally overwrite) a {documentPlan.ClassName}.
    /// .id must be set if there is no stable id generator defined
    /// .pk, .CreationDate and .Type are set automatically
    /// </summary>
    /// <exception cref=""Cosmogenesis.Core.DbOverloadedException"" />
    /// <exception cref=""Cosmogenesis.Core.DbUnknownStatusCodeException"" />
    internal protected virtual System.Threading.Tasks.Task<Cosmogenesis.Core.CreateOrReplaceResult<{documentPlan.FullTypeName}>> CreateOrReplaceAsync({documentPlan.FullTypeName} {documentPlan.ClassNameArgument})
    {{
        {DocumentModelWriter.CreateAndCheckPkAndId(partitionPlan, documentPlan, documentPlan.ClassNameArgument)}
        return this.CreateOrReplaceItemAsync(item: {documentPlan.ClassNameArgument}, type: {documentPlan.ConstDocType});
    }}
";
Пример #3
0
    static string Create(DatabasePlan databasePlan, PartitionPlan partitionPlan, DocumentPlan documentPlan) => $@"
    /// <summary>
    /// Queue a {documentPlan.ClassName} for creation in the batch
    /// </summary>
    protected virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} Create({documentPlan.FullTypeName} {documentPlan.ClassNameArgument})
    {{
        {DocumentModelWriter.CreateAndCheckPkAndId(partitionPlan, documentPlan, documentPlan.ClassNameArgument)}
        this.CreateCore(item: {documentPlan.ClassNameArgument}, type: {documentPlan.ConstDocType});
        return this;
    }}

    /// <summary>
    /// Queue a {documentPlan.ClassName} for creation in the batch
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} Create{documentPlan.ClassName}({documentPlan.PropertiesByName.Values.Where(x => !partitionPlan.GetPkPlan.ArgumentByPropertyName.ContainsKey(x.PropertyName)).AsInputParameters()}) =>
        this.Create({documentPlan.ClassNameArgument}: new {documentPlan.FullTypeName} {{ {partitionPlan.AsSettersFromDocumentPlanAndPartitionClass(documentPlan)} }});
";