Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TemporalTableSqlBuilder.cs #31

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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