From 94585fc3f22aa3f490384bbd3f9afb748c878d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Tue, 31 Jan 2023 12:46:59 +0100 Subject: [PATCH] Fix missing await when invoking OnInvalidating Fix equals calls on possibly null values in SelectExpression --- src/Connected.Entities/Caching/EntityCacheClient.cs | 6 +----- src/Connected.Expressions/Expressions/SelectExpression.cs | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Connected.Entities/Caching/EntityCacheClient.cs b/src/Connected.Entities/Caching/EntityCacheClient.cs index 36dea51..c838313 100644 --- a/src/Connected.Entities/Caching/EntityCacheClient.cs +++ b/src/Connected.Entities/Caching/EntityCacheClient.cs @@ -62,7 +62,7 @@ public abstract class EntityCacheClient : StatefulCacheCli try { - if (OnInvalidating(ctx, id) is TEntity entity && entity is IPrimaryKey pk) + if ((await OnInvalidating(ctx, id)) is TEntity entity && entity is IPrimaryKey pk) Set(pk.Id, entity, TimeSpan.Zero); if (transaction is not null) @@ -82,10 +82,6 @@ public abstract class EntityCacheClient : StatefulCacheCli if (context.GetService() is not IStorageProvider provider) return default; - var entities = await provider.Open().AsEntities(); - - var entity = entities.FirstOrDefault(e => e.Id.Equals(id)); - return await (from dc in provider.Open() where TypeComparer.Compare(dc.Id, id) select dc).AsEntity(); diff --git a/src/Connected.Expressions/Expressions/SelectExpression.cs b/src/Connected.Expressions/Expressions/SelectExpression.cs index a548d24..f440208 100644 --- a/src/Connected.Expressions/Expressions/SelectExpression.cs +++ b/src/Connected.Expressions/Expressions/SelectExpression.cs @@ -55,9 +55,9 @@ public sealed class SelectExpression : AliasedExpression if (obj is not SelectExpression second) return false; - return Alias.Equals(second.Alias) - && Columns.Equals(second.Columns) - && From.Equals(second.From) + return Alias == second.Alias + && Columns == second.Columns + && From == second.From && Where == second.Where && OrderBy == second.OrderBy && GroupBy == second.GroupBy