|
@@ -691,21 +691,20 @@ public class SQLiteProviderFactory : IProviderFactory
|
|
|
var setNullFields = new List<string>();
|
|
|
var cascadeFields = new List<string>();
|
|
|
|
|
|
- var props = DatabaseSchema.RootProperties(otherType)
|
|
|
- .Where(x => x.IsEntityLink
|
|
|
- && x.PropertyType.GetInterfaceDefinition(typeof(IEntityLink<>))?.GenericTypeArguments[0] == type
|
|
|
+ var props = DatabaseSchema.LocalProperties(otherType)
|
|
|
+ .Where(x => x.Parent?.IsEntityLink == true
|
|
|
+ && x.Parent.PropertyType.GetInterfaceDefinition(typeof(IEntityLink<>))?.GenericTypeArguments[0] == type
|
|
|
&& !x.IsCalculated);
|
|
|
foreach(var prop in props)
|
|
|
{
|
|
|
- var fieldname = $"{prop.Name}.ID";
|
|
|
- if(prop.GetAttribute<EntityRelationshipAttribute>() is EntityRelationshipAttribute attr
|
|
|
+ if(prop.Parent?.GetAttribute<EntityRelationshipAttribute>() is EntityRelationshipAttribute attr
|
|
|
&& attr.Action == DeleteAction.Cascade)
|
|
|
{
|
|
|
- cascadeFields.Add(fieldname);
|
|
|
+ cascadeFields.Add(prop.Name);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- setNullFields.Add(fieldname);
|
|
|
+ setNullFields.Add(prop.Name);
|
|
|
}
|
|
|
}
|
|
|
cascadeFields.Sort();
|
|
@@ -715,7 +714,7 @@ public class SQLiteProviderFactory : IProviderFactory
|
|
|
{
|
|
|
cascades.Add(new(otherType, cascadeFields));
|
|
|
}
|
|
|
- if(setNulls.Count > 0)
|
|
|
+ if(setNullFields.Count > 0)
|
|
|
{
|
|
|
setNulls.Add(new(otherType, setNullFields));
|
|
|
}
|