Skip to content

Commit

Permalink
Merge pull request #31 from awjacobson/master
Browse files Browse the repository at this point in the history
Update TemporalTableSqlBuilder.cs
  • Loading branch information
findulov committed Jun 23, 2021
2 parents 870cb04 + 7357025 commit 57f3a3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Authors>George Findulov</Authors>
<Company />
<Version>1.1.0</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<Version>1.1.1</Version>
<AssemblyVersion>1.1.1.0</AssemblyVersion>
<FileVersion>1.1.1.0</FileVersion>
<RepositoryUrl>https://github.com/findulov/EntityFrameworkCore.TemporalTables</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/findulov/EntityFrameworkCore.TemporalTables</PackageProjectUrl>
Expand Down
31 changes: 17 additions & 14 deletions EntityFrameworkCore.TemporalTables/Sql/TemporalTableSqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ private string BuildTemporalTableSqlFromEntityTypeConfiguration(IEntityType enti
if (relationalEntityType is IEntityType)
{

string tableName = relationalEntityType.GetTableName();
string schema = relationalEntityType.GetSchema() ?? "dbo";
string tableName = relationalEntityType.GetTableName();
if (tableName is not null) // the above returns null if not mapped to a table (views)
{
string schema = relationalEntityType.GetSchema() ?? "dbo";

bool isEntityConfigurationTemporal = TemporalEntitiesCache.IsEntityConfigurationTemporal(entityType);
bool isEntityTemporalInDatabase = tableHelper.IsTableTemporal(tableName, schema);
bool isEntityConfigurationTemporal = TemporalEntitiesCache.IsEntityConfigurationTemporal(entityType);
bool isEntityTemporalInDatabase = tableHelper.IsTableTemporal(tableName, schema);

ITemporalTableSqlGenerator temporalTableSqlGenerator = temporalTableSqlGeneratorFactory
.CreateInstance(isEntityConfigurationTemporal, isEntityTemporalInDatabase, tableName, schema);
ITemporalTableSqlGenerator temporalTableSqlGenerator = temporalTableSqlGeneratorFactory
.CreateInstance(isEntityConfigurationTemporal, isEntityTemporalInDatabase, tableName, schema);

string temporalTableSql = temporalTableSqlGenerator.Generate();
string temporalTableSql = temporalTableSqlGenerator.Generate();

if (!string.IsNullOrWhiteSpace(temporalTableSql))
{
sqlBuilder.AppendLine(temporalTableSql);
if (!string.IsNullOrWhiteSpace(temporalTableSql))
{
sqlBuilder.AppendLine(temporalTableSql);

if (appendSeparator)
{
sqlBuilder.AppendLine(new string('-', 100));
if (appendSeparator)
{
sqlBuilder.AppendLine(new string('-', 100));
}
}
}
}
}
return sqlBuilder.ToString();
}
Expand Down

0 comments on commit 57f3a3f

Please sign in to comment.