public static CSharpClassDefinition GetRepositoryBaseClassDefinition(this DapperProject project) { var classDefinition = new CSharpClassDefinition(); classDefinition.Namespaces.Add("System"); classDefinition.Namespaces.Add("System.Linq"); classDefinition.Namespaces.Add("System.Threading.Tasks"); classDefinition.Namespaces.Add("Microsoft.Extensions.Options"); classDefinition.Namespaces.Add(project.GetEntityLayerNamespace()); classDefinition.Namespace = project.GetDataLayerContractsNamespace(); classDefinition.Name = "Repository"; classDefinition.Constructors.Add(new ClassConstructorDefinition(new ParameterDefinition("IOptions<AppSettings>", "appSettings")) { Lines = new List <ILine> { new CodeLine("ConnectionString = appSettings.Value.ConnectionString;") } }); classDefinition.Properties.Add(new PropertyDefinition("String", "ConnectionString ") { AccessModifier = AccessModifier.Protected, IsReadOnly = true }); return(classDefinition); }
public static RepositoryBaseClassDefinition GetRepositoryBaseClassDefinition(this DapperProject project) => new RepositoryBaseClassDefinition { Namespaces = { "System.Data", project.GetEntityLayerNamespace() }, Namespace = project.GetDataLayerContractsNamespace(), AccessModifier = AccessModifier.Public, Name = "Repository", Constructors = { new ClassConstructorDefinition(AccessModifier.Public, new ParameterDefinition("IDbConnection", "connection")) { Lines = { new CodeLine("Connection = connection;") } } }, Properties = { new PropertyDefinition(AccessModifier.Protected, "IDbConnection", "Connection") { IsReadOnly = true } } };
public static RepositoryInterfaceDefinition GetRepositoryInterfaceDefinition(this DapperProject project) => new RepositoryInterfaceDefinition { Namespace = project.GetDataLayerContractsNamespace(), AccessModifier = AccessModifier.Public, Name = "IRepository" };
public static RepositoryInterfaceDefinition GetRepositoryInterfaceDefinition(this DapperProject project) { return(new RepositoryInterfaceDefinition { Namespace = project.GetDataLayerContractsNamespace(), Name = "IRepository" }); }