var columns = string.Join(", ", columnEnumerable);
var foreignKeys = entityType.GetForeignKeys()
.Where(static fk => fk.DeleteBehavior is DeleteBehavior.Cascade or DeleteBehavior.SetNull)
.Where(static fk =>
{
var annotationValue = fk.PrincipalEntityType
.FindAnnotation(EntityModelBuilderExtensions._queryViewAnnotationName)?.Value as List<Type>;
return annotationValue
?.Any(static t =>
t == typeof(ILogicallyDeletable) || t == typeof(IDependencyLogicallyDeletable)) is true;
})
.Select(fk => BuildJoinInfo(entityType, fk))
.ToList();
if (foreignKeys.Count == 0) throw new InvalidOperationException($"实体{entityType.Name}没有支持逻辑删除或依赖项逻辑删除的级联外键,无需实现{nameof(IDependencyLogicallyDeletable)}接口。");
var principalLogicallyDeleteColumns = string.Join(
if (foreignKey.Properties.Count != foreignKey.PrincipalKey.Properties.Count) throw new InvalidOperationException($"外键和主键字段数量不一致。外键实体:{entityType.Name};主实体:{foreignKey.PrincipalEntityType.Name}");
var principalEntityType = foreignKey.PrincipalEntityType;
var principalIsDependencyLogicallyDeletableEntity = (principalEntityType
.FindAnnotation(EntityModelBuilderExtensions._queryViewAnnotationName)?.Value as List<Type>)
?.Any(static t => t == typeof(IDependencyLogicallyDeletable)) is true;
var principalDataSourceName = principalIsDependencyLogicallyDeletableEntity
? principalEntityType.GetViewName()!
: principalEntityType.GetTableName()!;
var principalDataSourceIdentifier = principalIsDependencyLogicallyDeletableEntity
var entrySetDict = eventData.Context.ChangeTracker.Entries()
.GroupBy(static e => e.Metadata)
.Select(static group => group.Key.FindRuntimeAnnotationValue(LogicallyDeletedRuntimeAnnotation) as ConcurrentDictionary<DbContext, HashSet<EntityEntry>>)
FROM (VALUES ([QueryView_Entity1_1s].[DeletedAt]), ([QueryView_Entity1_1s].[MyDependencyDeletedAt])) AS DeleteTimeTable([DeletedAt])) AS [DependencyDeletedAt]
FROM [Entity3s]
LEFT JOIN [QueryView_Entity1_1s]
ON [Entity3s].[Entity1_1Id] = [QueryView_Entity1_1s].[Id];