private CSharpRepoGenerator.RepositoryFunction GenerateBatchList(RepositoryMemberInfo repositoryMembmerInfo) { string returnType = GetClassName(repositoryMembmerInfo); var mainKey = repositoryMembmerInfo.Info.QueryKey; string mainKeyType = GetMemberType(mainKey); string mainKeyRealType = new CSharpDefaultTypeFinder(mainKey.Optional).Visit(mainKey.MemberType); string casting = Config.Entities.StrongTypes ? $"Select(id => ({mainKeyRealType})id).ToList()." : string.Empty; var signature = $"Task<List<{returnType}>> GetMany(IEnumerable<{mainKeyType}> ids)"; var template = $@" public async {signature} {{ using (var db = GetDb()) {{ var payload = new {{ LookupKeys = ids.{casting}ToDataTable() }}; var result = await db.QuerySprocAsync<{returnType}>(""{repositoryMembmerInfo.Info.Name}"", payload).ConfigureAwait(continueOnCapturedContext: false); return result.ToList(); }} }}"; return(new CSharpRepoGenerator.RepositoryFunction { Body = template, Signature = signature }); }
private string EnumDefinition(ProjectedAtomRoot arg) { var members = arg.BasedOn.Lookup.Values.Select((value, idx) => GetEnumDefinitionType(value, idx, arg.BasedOn.Lookup.NamePrefix)); string enumMembers = string.Join("," + Environment.NewLine, members.IndentAllLines(1)); var type = new CSharpDefaultTypeFinder(optional: false).Visit(arg.BasedOn.Members.First().MemberType); var template = $@" [Serializable, DataContract] public enum {arg.Name} : {type} {{ {enumMembers} }} "; return(template); }