-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/ignore-audit-trail-attribute
- Loading branch information
Showing
59 changed files
with
1,778 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
|
||
public interface ISoftDeletable | ||
{ | ||
|
||
DateTimeOffset? Deleted { get; set; } | ||
Guid? DeletedBy { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/api/framework/Infrastructure/Persistence/AppendGlobalQueryFilterExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Linq.Expressions; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Query; | ||
|
||
namespace FSH.Framework.Infrastructure.Persistence; | ||
|
||
internal static class ModelBuilderExtensions | ||
{ | ||
public static ModelBuilder AppendGlobalQueryFilter<TInterface>(this ModelBuilder modelBuilder, Expression<Func<TInterface, bool>> filter) | ||
{ | ||
// get a list of entities without a baseType that implement the interface TInterface | ||
var entities = modelBuilder.Model.GetEntityTypes() | ||
.Where(e => e.BaseType is null && e.ClrType.GetInterface(typeof(TInterface).Name) is not null) | ||
.Select(e => e.ClrType); | ||
|
||
foreach (var entity in entities) | ||
{ | ||
var parameterType = Expression.Parameter(modelBuilder.Entity(entity).Metadata.ClrType); | ||
var filterBody = ReplacingExpressionVisitor.Replace(filter.Parameters.Single(), parameterType, filter.Body); | ||
|
||
// get the existing query filter | ||
if (modelBuilder.Entity(entity).Metadata.GetQueryFilter() is { } existingFilter) | ||
{ | ||
var existingFilterBody = ReplacingExpressionVisitor.Replace(existingFilter.Parameters.Single(), parameterType, existingFilter.Body); | ||
|
||
// combine the existing query filter with the new query filter | ||
filterBody = Expression.AndAlso(existingFilterBody, filterBody); | ||
} | ||
|
||
// apply the new query filter | ||
modelBuilder.Entity(entity).HasQueryFilter(Expression.Lambda(filterBody, parameterType)); | ||
} | ||
|
||
return modelBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/api/migrations/PostgreSQL/Catalog/20240601095057_Add Catalog Schema.cs
This file was deleted.
Oops, something went wrong.
57 changes: 55 additions & 2 deletions
57
...0601095057_Add Catalog Schema.Designer.cs → ...1116102306_Add Catalog Schema.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.