Skip to content

Commit d0cdf6e

Browse files
committed
fix 2sic/2sxc#3584 Adding 2sxc Content module results with Error: System.ArgumentNullException
1 parent 36551e1 commit d0cdf6e

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

ToSic.Eav.Repository.Efc/Parts/DbEntity_read.cs

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace ToSic.Eav.Repository.Efc.Parts;
1+
using System.Linq;
2+
3+
namespace ToSic.Eav.Repository.Efc.Parts;
24

35
partial class DbEntity
46
{
@@ -35,15 +37,19 @@ internal ToSicEavEntities GetDbEntity(int entityId)
3537
internal ToSicEavEntities[] GetDbEntities(int[] repositoryIds)
3638
{
3739
var callLog = DbContext.Log.Fn<ToSicEavEntities[]>($"Get {repositoryIds.Length}", timer: true);
38-
var found = EntityQuery.Where(e => repositoryIds.Contains(e.EntityId)).ToArray();
40+
// commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0
41+
// var found = EntityQuery.Where(e => repositoryIds.Contains(e.EntityId)).ToArray();
42+
var found = EntityQuery.Where(e => Enumerable.Contains(repositoryIds, e.EntityId)).ToArray();
3943
return callLog.Return(found, found.Length.ToString());
4044
}
4145

4246
//private ToSicEavEntities GetDbEntity(int entityId, string includes)
4347
// => IncludeMultiple(EntityQuery, includes).Single(e => e.EntityId == entityId);
4448

4549
private List<ToSicEavEntities> GetDbEntities(int[] entityIds, string includes)
46-
=> IncludeMultiple(EntityQuery, includes).Where(e => entityIds.Contains(e.EntityId)).ToList();
50+
// commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0
51+
// => IncludeMultiple(EntityQuery, includes).Where(e => entityIds.Contains(e.EntityId)).ToList();
52+
=> IncludeMultiple(EntityQuery, includes).Where(e => Enumerable.Contains(entityIds, e.EntityId)).ToList();
4753

4854
private static IQueryable<ToSicEavEntities> IncludeMultiple(IQueryable<ToSicEavEntities> origQuery, string additionalTables)
4955
{
@@ -68,7 +74,9 @@ internal IQueryable<ToSicEavEntities> GetEntitiesByGuid(Guid entityGuid)
6874
=> EntityQuery.Where(e => e.EntityGuid == entityGuid
6975
&& !e.ChangeLogDeleted.HasValue
7076
&& !e.AttributeSet.ChangeLogDeleted.HasValue
71-
&& DbContext.AppIds.Contains(e.AppId));
77+
// commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0
78+
// && DbContext.AppIds.Contains(e.AppId));
79+
&& Enumerable.Contains(DbContext.AppIds, e.AppId));
7280

7381
/// <summary>
7482
/// Get a single Entity by EntityGuid. Ensure it's not deleted and has context's AppId
@@ -105,10 +113,15 @@ internal Dictionary<Guid, int> GetMostCurrentDbEntities(Guid[] entityGuids)
105113
// 2020-10-07 2dm experiment with fewer requests
106114
internal IQueryable<ToSicEavEntities> GetEntitiesByGuid(Guid[] entityGuid)
107115
=> EntityQuery
108-
.Where(e => entityGuid.Contains(e.EntityGuid)
116+
.Where(e =>
117+
// commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0
118+
// entityGuid.Contains(e.EntityGuid)
119+
Enumerable.Contains(entityGuid, e.EntityGuid)
109120
&& e.ChangeLogDeleted == null
110121
&& e.AttributeSet.ChangeLogDeleted == null
111-
&& DbContext.AppIds.Contains(e.AppId)
122+
// commented because of https://github.com/npgsql/efcore.pg/issues/3461, we can go back with net10.0
123+
// && DbContext.AppIds.Contains(e.AppId)
124+
&& Enumerable.Contains(DbContext.AppIds, e.AppId)
112125
);
113126

114127

0 commit comments

Comments
 (0)