public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (DataStructureInfo)conceptInfo; var orm = info as IOrmDataStructure; if (orm != null) { string module = info.Module.Name; string entity = info.Name; DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, $"EntityBase<{module}.{entity}>", typeof(EntityBase <>), info); RepositoryHelper.GenerateQueryableRepository(info, codeBuilder, QuerySnippet(info)); codeBuilder.InsertCode($"Common.OrmRepositoryBase<Common.Queryable.{module}_{entity}, {module}.{entity}>", RepositoryHelper.OverrideBaseTypeTag, info); codeBuilder.InsertCode( string.Format("public System.Data.Entity.DbSet<Common.Queryable.{0}_{1}> {0}_{1} {{ get; set; }}\r\n ", info.Module.Name, info.Name), DomInitializationCodeGenerator.EntityFrameworkContextMembersTag); codeBuilder.InsertCode( string.Format("modelBuilder.Ignore<global::{0}.{1}>();\r\n " + "modelBuilder.Entity<Common.Queryable.{0}_{1}>().Map(m => {{ m.MapInheritedProperties(); m.ToTable(\"{3}\", \"{2}\"); }});\r\n ", info.Module.Name, info.Name, orm.GetOrmSchema(), orm.GetOrmDatabaseObject()), DomInitializationCodeGenerator.EntityFrameworkOnModelCreatingTag); } }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (BrowseDataStructureInfo)conceptInfo; string module = info.Module.Name; string entity = info.Name; DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, $"EntityBase<{module}.{entity}>", typeof(EntityBase <>), info); RepositoryHelper.GenerateQueryableRepository(info, codeBuilder, $"return Query(_domRepository.{info.Source.Module.Name}.{info.Source.Name}.Query());"); string querySnippet = $@"public IQueryable<Common.Queryable.{module}_{entity}> Query(IQueryable<Common.Queryable.{info.Source.Module.Name}_{info.Source.Name}> source) {{ return source.Select(item => new Common.Queryable.{module}_{entity} {{ ID = item.ID, Base = item, {BrowsePropertiesTag.Evaluate(info)} }}); }} "; codeBuilder.InsertCode(querySnippet, RepositoryHelper.RepositoryMembers, info); codeBuilder.InsertCode($"Common.OrmRepositoryBase<Common.Queryable.{module}_{entity}, {module}.{entity}>", RepositoryHelper.OverrideBaseTypeTag, info); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (DataStructureInfo)conceptInfo; var orm = info as IOrmDataStructure; if (orm != null) { codeBuilder.InsertCode(SnippetEntityClassMembers(info), DataStructureCodeGenerator.BodyTag, info); DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, string.Format("System.IEquatable<{0}>", info.Name), typeof(System.IEquatable <>), info); RepositoryHelper.GenerateRepository(info, codeBuilder); RepositoryHelper.GenerateQueryableRepositoryFunctions(info, codeBuilder, QuerySnippet(info)); codeBuilder.InsertCode(SnippetQueryableFilterById(info), RepositoryHelper.RepositoryMembers, info); PropertyInfo idProperty = new PropertyInfo { DataStructure = info, Name = "ID" }; PropertyHelper.GenerateCodeForType(idProperty, codeBuilder, "Guid"); DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, typeof(IEntity), info); codeBuilder.InsertCode( string.Format("public System.Data.Entity.DbSet<Common.Queryable.{0}_{1}> {0}_{1} {{ get; set; }}\r\n ", info.Module.Name, info.Name), DomInitializationCodeGenerator.EntityFrameworkContextMembersTag); codeBuilder.InsertCode( string.Format("modelBuilder.Ignore<global::{0}.{1}>();\r\n " + "modelBuilder.Entity<Common.Queryable.{0}_{1}>().Map(m => {{ m.MapInheritedProperties(); m.ToTable(\"{3}\", \"{2}\"); }});\r\n ", info.Module.Name, info.Name, orm.GetOrmSchema(), orm.GetOrmDatabaseObject()), DomInitializationCodeGenerator.EntityFrameworkOnModelCreatingTag); } }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (QueryableExtensionInfo)conceptInfo; DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, $"EntityBase<{info.Module.Name}.{info.Name}>", typeof(EntityBase <>), info); RepositoryHelper.GenerateQueryableRepository(info, codeBuilder, QuerySnippet(info)); codeBuilder.InsertCode(RepositoryFunctionsSnippet(info), RepositoryHelper.RepositoryMembers, info); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (ComputedInfo)conceptInfo; string loadFunctionBodySnippet = $@"Func<Common.DomRepository{DataStructureUtility.ComputationAdditionalParametersTypeTag.Evaluate(info)}, global::{info.Module.Name}.{info.Name}[]> compute_Function = {info.Expression}; return compute_Function(_domRepository{DataStructureUtility.ComputationAdditionalParametersArgumentTag.Evaluate(info)});"; RepositoryHelper.GenerateReadableRepository(info, codeBuilder, loadFunctionBodySnippet); DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, $"EntityBase<{info.Module.Name}.{info.Name}>", typeof(EntityBase <>), info); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (ComputedInfo)conceptInfo; RepositoryHelper.GenerateRepository(info, codeBuilder); RepositoryHelper.GenerateQueryableRepositoryFunctions(info, codeBuilder, null, LoadFunctionBodySnippet(info)); codeBuilder.InsertCode(RepositoryFunctionsSnippet(info), RepositoryHelper.RepositoryMembers, info); PropertyInfo idProperty = new PropertyInfo { DataStructure = info, Name = "ID" }; PropertyHelper.GenerateCodeForType(idProperty, codeBuilder, "Guid"); DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, typeof(IEntity), info); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (QueryableExtensionInfo)conceptInfo; string parameterTypesTag = DataStructureUtility.ComputationAdditionalParametersTypeTag.Evaluate(info); string parameterArgsTag = DataStructureUtility.ComputationAdditionalParametersArgumentTag.Evaluate(info); string baseIQueryable = $"IQueryable<Common.Queryable.{info.Base.Module.Name}_{info.Base.Name}>"; string extensionIQueryable = $"IQueryable<Common.Queryable.{info.Module.Name}_{info.Name}>"; string querySnippet = $@"Func<{baseIQueryable}, Common.DomRepository{parameterTypesTag}, {extensionIQueryable}> Compute = {info.Expression}; return Compute(_domRepository.{info.Base.FullName}.Query(), _domRepository{parameterArgsTag});"; DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, $"EntityBase<{info.FullName}>", typeof(EntityBase <>), info); RepositoryHelper.GenerateQueryableRepository(info, codeBuilder, querySnippet); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (QueryableExtensionInfo)conceptInfo; codeBuilder.InsertCode(CodeSnippet(info), DataStructureCodeGenerator.BodyTag, info); DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, string.Format("System.IEquatable<{0}>", info.Name), typeof(IEquatable <>), info); RepositoryHelper.GenerateRepository(info, codeBuilder); RepositoryHelper.GenerateQueryableRepositoryFunctions(info, codeBuilder, QuerySnippet(info)); codeBuilder.InsertCode(RepositoryFunctionsSnippet(info), RepositoryHelper.RepositoryMembers, info); PropertyInfo idProperty = new PropertyInfo { DataStructure = info, Name = "ID" }; PropertyHelper.GenerateCodeForType(idProperty, codeBuilder, "Guid"); DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, typeof(IEntity), info); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { var info = (DataStructureInfo)conceptInfo; if (info is IOrmDataStructure) { string module = info.Module.Name; string entity = info.Name; DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, $"EntityBase<{module}.{entity}>", typeof(EntityBase <>), info); RepositoryHelper.GenerateQueryableRepository(info, codeBuilder); codeBuilder.InsertCode($"Common.OrmRepositoryBase<Common.Queryable.{module}_{entity}, {module}.{entity}>", RepositoryHelper.OverrideBaseTypeTag, info); codeBuilder.InsertCode( string.Format("public System.Data.Entity.DbSet<Common.Queryable.{0}_{1}> {0}_{1} {{ get; set; }}\r\n ", info.Module.Name, info.Name), DomInitializationCodeGenerator.EntityFrameworkContextMembersTag); } }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { ImplementsInterfaceInfo info = (ImplementsInterfaceInfo)conceptInfo; DataStructureCodeGenerator.AddInterfaceAndReference(codeBuilder, info.GetInterfaceType(), info.DataStructure); }