Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lebee committed Oct 16, 2018
2 parents f1d7e62 + 4d28329 commit 8b8d988
Show file tree
Hide file tree
Showing 54 changed files with 2,190 additions and 768 deletions.
2 changes: 2 additions & 0 deletions PoweredSoft.DbUtils.EF.Generator.Core/IGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ public interface IGenerator
void Generate();
void LoadOptionsFromJson(string configFile);
List<ITable> ResolveTablesToGenerate();
List<ISequence> ResolveSequencesToGenerate();
IGeneratorOptions GetOptions();
IGeneratorOptions GetDefaultOptions();
void InitializeOptionsWithDefault();
}

public interface IGenerator<TOptions> : IGenerator
Expand Down
1 change: 1 addition & 0 deletions PoweredSoft.DbUtils.EF.Generator.Core/IGeneratorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public interface IGeneratorOptions
string ModelInterfaceSuffix { get; set; }
List<string> ModelInheritances { get; set; }
string Version { get; }
string Engine { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -9,6 +9,7 @@
<RepositoryType>github</RepositoryType>
<PackageIconUrl></PackageIconUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions PoweredSoft.DbUtils.EF.Generator.EF6.Core/IEF6GeneratorOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
using PoweredSoft.DbUtils.EF.Generator.Core;

namespace PoweredSoft.DbUtils.EF.Generator.EF6.Core
{
public interface IEF6GeneratorOptions : IGeneratorOptions
{
string ConnectionStringName { get; set; }
string FluentConfigurationClassSuffix { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.3</Version>
<Copyright>Powered Softwares Inc.</Copyright>
<PackageLicenseUrl>https://github.com/PoweredSoft/DbUtils/blob/master/LICENSE.md</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/PoweredSoft/DbUtils</PackageProjectUrl>
<RepositoryUrl>https://github.com/PoweredSoft/DbUtils/PoweredSoft.DbUtils.EF.Generator.SqlServer.EF6</RepositoryUrl>
<RepositoryUrl>https://github.com/PoweredSoft/DbUtils/PoweredSoft.DbUtils.EF.Generator.EF6.Core</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageIconUrl></PackageIconUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.SqlServer\PoweredSoft.DbUtils.EF.Generator.SqlServer.csproj" />
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.Core\PoweredSoft.DbUtils.EF.Generator.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using PoweredSoft.CodeGenerator;
using PoweredSoft.DbUtils.EF.Generator.Core;
using PoweredSoft.DbUtils.EF.Generator.SqlServer;
using PoweredSoft.DbUtils.Schema.Core;
using PoweredSoft.DbUtils.Schema.SqlServer;

namespace PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer
{
public class DatabaseGenerator : EF6DatabaseGeneratorBase<IDatabaseSchema, GeneratorOptions>
{
protected override IDataTypeResolver DataTypeResolver { get; } = new DataTypeResolver();
public override IDatabaseSchema CreateSchema() => new DatabaseSchema();
public override IGeneratorOptions GetDefaultOptions() => new GeneratorOptions();

public override void InitializeOptionsWithDefault()
{
Options = GetDefaultOptions() as GeneratorOptions;;
}

protected override void GenerateGetNextSequenceLines(MethodBuilder method, string outputType, ISequence sequence)
{
var sqlServerSequence = (Sequence)sequence;
method.RawLine($"return Database.SqlQuery<{outputType}>(\"SELECT NEXT VALUE FOR [{sqlServerSequence.Schema}].[{sequence.Name}];\").First()");
}

protected override string EmptyMetas(string text) => base.EmptyMetas(text).EmptyMetas();
protected override string ReplaceMetas(string text, ITable table) => base.ReplaceMetas(text, table).ReplaceMetas((Table)table);
public override List<ITable> ResolveTablesToGenerate() => base.ResolveTablesToGenerate().ShouldGenerate(Options);
public override List<ISequence> ResolveSequencesToGenerate() => base.ResolveSequencesToGenerate().ShouldGenerate(Options);

protected override bool IsGenerateOptionIdentity(IColumn column)
{
if (column.DefaultValue?.IndexOf("newsequentialid", StringComparison.InvariantCultureIgnoreCase) > -1)
return true;

return base.IsGenerateOptionIdentity(column);
}

protected override string ToTableFluent(ITable table)
{
var sqlServerTable = (Table)table;
return $"ToTable(\"{table.Name}\", \"{sqlServerTable.Schema}\")";
}
}
}
41 changes: 41 additions & 0 deletions PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer/GeneratorOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Text;
using PoweredSoft.DbUtils.EF.Generator.EF6.Core;
using PoweredSoft.DbUtils.EF.Generator.SqlServer.Core;

namespace PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer
{
public class GeneratorOptions : IEF6GeneratorOptions, ISqlServerGeneratorOptions
{
public List<string> ExcludedTables { get; set; } = new List<string>()
{
"dbo.sysdiagrams"
};

public List<string> IncludedTables { get; set; } = new List<string>();
public string Namespace { get; set; }
public string ContextName { get; set; }
public string ContextBaseClassName { get; set; } = "System.Data.Entity.DbContext";
public string ConnectionString { get; set; }
public string OutputDir { get; set; }
public bool CleanOutputDir { get; set; } = false;
public bool OutputToSingleFile => !string.IsNullOrWhiteSpace(OutputSingleFileName);
public bool GenerateContextSequenceMethods { get; set; }
public string OutputSingleFileName { get; set; }
public bool GenerateInterfaces { get; set; } = false;
public string InterfaceNameSuffix { get; set; } = "";
public bool GenerateModels { get; set; } = false;
public bool GenerateModelsInterfaces { get; set; } = false;
public bool GenerateModelPropertyAsNullable { get; set; } = false;
public string ModelSuffix { get; set; } = "Base";
public string ModelInterfaceSuffix { get; set; } = "";
public List<string> ModelInheritances { get; set; } = new List<string>();
public string Version => "6";
public string Engine => "SqlServer";
public string ConnectionStringName { get; set; }
public string FluentConfigurationClassSuffix { get; set; } = "FluentConfiguration";
public List<string> IncludedSchemas { get; } = new List<string>();
public List<string> ExcludedSchemas { get; } = new List<string>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.3</Version>
<Copyright>Powered Softwares Inc.</Copyright>
<PackageLicenseUrl>https://github.com/PoweredSoft/DbUtils/blob/master/LICENSE.md</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/PoweredSoft/DbUtils</PackageProjectUrl>
<RepositoryUrl>https://github.com/PoweredSoft/DbUtils/PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageIconUrl></PackageIconUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.EF6.Core\PoweredSoft.DbUtils.EF.Generator.EF6.Core.csproj" />
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.EF6\PoweredSoft.DbUtils.EF.Generator.EF6.csproj" />
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.SqlServer\PoweredSoft.DbUtils.EF.Generator.SqlServer.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 8b8d988

Please sign in to comment.