|
1 | 1 | using ToSic.Eav.Apps.Internal.Specs;
|
2 | 2 | using ToSic.Eav.Serialization;
|
3 | 3 | using JsonSerializer = System.Text.Json.JsonSerializer;
|
| 4 | +// ReSharper disable InvokeAsExtensionMethod |
4 | 5 |
|
5 | 6 | namespace ToSic.Eav.Repository.Efc.Parts;
|
6 | 7 |
|
@@ -102,38 +103,60 @@ internal void DeleteApp(int appId, bool fullDelete)
|
102 | 103 | private void DeleteAppWithoutStoredProcedure(int appId, bool alsoDeleteAppEntry)
|
103 | 104 | {
|
104 | 105 | var db = DbContext.SqlDb;
|
105 |
| - var appContentTypes = db.ToSicEavAttributeSets.Where(a => a.AppId == appId).ToList(); |
106 |
| - var contentTypeIds = appContentTypes.Select(ct => ct.AttributeSetId).ToArray(); |
| 106 | + var appContentTypes = db.ToSicEavAttributeSets |
| 107 | + .Where(a => a.AppId == appId) |
| 108 | + .ToList(); |
| 109 | + var contentTypeIds = appContentTypes |
| 110 | + .Select(ct => ct.AttributeSetId) |
| 111 | + .ToArray(); |
107 | 112 |
|
108 | 113 | // WIP v13 - now with Inherited Apps, we have entities which point to a content-type which doesn't belong to the App itself
|
109 | 114 | const bool useV12Method = false;
|
110 | 115 | var appEntities = useV12Method
|
111 |
| - ? db.ToSicEavEntities.Where(e => appContentTypes.Contains(e.AttributeSet)) |
| 116 | + // commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0 |
| 117 | + //? db.ToSicEavEntities.Where(e => appContentTypes.Contains(e.AttributeSet)) |
| 118 | + ? db.ToSicEavEntities.Where(e => Enumerable.Contains(appContentTypes, e.AttributeSet)) |
112 | 119 | : db.ToSicEavEntities.Where(e => e.AppId == appId);
|
113 | 120 |
|
114 | 121 | var entityIds = appEntities.Select(e => e.EntityId).ToArray();
|
115 | 122 |
|
116 | 123 | // Delete Value-Dimensions
|
117 |
| - var appValues = db.ToSicEavValues.Where(v => entityIds.Contains(v.EntityId)); |
118 |
| - var appValueIds = appValues.Select(a => a.ValueId).ToList(); |
119 |
| - var valDimensions = db.ToSicEavValuesDimensions.Where(vd => appValueIds.Contains(vd.ValueId)); |
| 124 | + var appValues = db.ToSicEavValues |
| 125 | + // commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0 |
| 126 | + //.Where(v => entityIds.Contains(v.EntityId)); |
| 127 | + .Where(v => Enumerable.Contains(entityIds, v.EntityId)); |
| 128 | + var appValueIds = appValues |
| 129 | + .Select(a => a.ValueId) |
| 130 | + .ToList(); |
| 131 | + var valDimensions = db.ToSicEavValuesDimensions |
| 132 | + // commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0 |
| 133 | + //.Where(vd => appValueIds.Contains(vd.ValueId)); |
| 134 | + .Where(vd => Enumerable.Contains(appValueIds, vd.ValueId)); |
120 | 135 | db.RemoveRange(valDimensions);
|
121 | 136 | db.RemoveRange(appValues.ToList());
|
122 | 137 |
|
123 | 138 |
|
124 | 139 | // Delete Parent-EntityRelationships & Child-EntityRelationships
|
125 | 140 | var dbRelTable = db.ToSicEavEntityRelationships;
|
126 |
| - var relationshipsWithAppParents = dbRelTable.Where(rel => entityIds.Contains(rel.ParentEntityId)); |
| 141 | + var relationshipsWithAppParents = dbRelTable |
| 142 | + // commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0 |
| 143 | + //.Where(rel => entityIds.Contains(rel.ParentEntityId)); |
| 144 | + .Where(rel => Enumerable.Contains(entityIds, rel.ParentEntityId)); |
127 | 145 | db.RemoveRange(relationshipsWithAppParents.ToList());
|
128 |
| - var relationshipsWithAppChildren = dbRelTable.Where(rel => entityIds.Contains(rel.ChildEntityId ?? -1)); |
| 146 | + var relationshipsWithAppChildren = dbRelTable |
| 147 | + // commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0 |
| 148 | + //.Where(rel => entityIds.Contains(rel.ChildEntityId ?? -1)); |
| 149 | + .Where(rel => Enumerable.Contains(entityIds, rel.ChildEntityId ?? -1)); |
129 | 150 | db.RemoveRange(relationshipsWithAppChildren.ToList());
|
130 | 151 |
|
131 | 152 | // Delete Entities
|
132 | 153 | db.RemoveRange(appEntities);
|
133 | 154 |
|
134 | 155 | // Delete Attributes
|
135 |
| - var attributeSetMappings = |
136 |
| - db.ToSicEavAttributesInSets.Where(aInS => contentTypeIds.Contains(aInS.AttributeSetId)); |
| 156 | + var attributeSetMappings = db.ToSicEavAttributesInSets |
| 157 | + // commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0 |
| 158 | + //.Where(aInS => contentTypeIds.Contains(aInS.AttributeSetId)); |
| 159 | + .Where(aInS => Enumerable.Contains(contentTypeIds, aInS.AttributeSetId)); |
137 | 160 | var attributes = attributeSetMappings.Select(asm => asm.Attribute);
|
138 | 161 | db.RemoveRange(attributes.ToList());
|
139 | 162 |
|
|
0 commit comments