Browse Source

Fixed Issue with BeforeDelete Triggers and ChildEntityAttributes

frogsoftware 1 năm trước cách đây
mục cha
commit
269313900e
1 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 4 3
      inabox.database.sqlite/SQLiteProvider.cs

+ 4 - 3
inabox.database.sqlite/SQLiteProvider.cs

@@ -610,10 +610,11 @@ namespace InABox.Database.SQLite
                 var cascadeFields = new List<string>();
 
                 var props = DatabaseSchema.RootProperties(otherType)
-                    .Where(x => x.IsEntityLink && x.PropertyType.GetInterfaceDefinition(typeof(IEntityLink<>))?.GenericTypeArguments[0] == type);
+                    .Where(x => x.IsEntityLink 
+                                && x.PropertyType.GetInterfaceDefinition(typeof(IEntityLink<>))?.GenericTypeArguments[0] == type
+                                && !x.HasAttribute<ChildEntityAttribute>());
                 foreach(var prop in props)
-                {
-                    var fieldname = $"{prop.Name}.ID";
+                {                    var fieldname = $"{prop.Name}.ID";
                     if(prop.GetAttribute<EntityRelationshipAttribute>() is EntityRelationshipAttribute attr
                         && attr.Action == DeleteAction.Cascade)
                     {