Skip to content

Commit 4b4783a

Browse files
committed
fix: This operation is only valid on generic types and InternalGet returning all table records due to GetPredicate not returning the correct predicate.
Related PR on tmsmith/DapperExtensions (tmsmith#325)
1 parent ae74414 commit 4b4783a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

DapperExtensions/DapperImplementor.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ protected static IPredicate GetPredicate(IClassMapper classMap, object predicate
288288
var wherePredicate = predicate as IPredicate;
289289
if (wherePredicate == null && predicate != null)
290290
{
291-
wherePredicate = GetEntityPredicate(classMap, predicate);
291+
wherePredicate = GetIdPredicate(classMap, predicate);
292292
}
293293

294294
return wherePredicate;
@@ -505,7 +505,14 @@ protected virtual DynamicParameters AddParameter<T>(T entity, DynamicParameters
505505

506506
parameters ??= new DynamicParameters();
507507

508-
if (prop.MemberInfo.DeclaringType == typeof(bool) || (prop.MemberInfo.DeclaringType.IsGenericType && prop.MemberType.GetGenericTypeDefinition() == typeof(Nullable<>) && prop.MemberInfo.DeclaringType.GetGenericArguments()[0] == typeof(bool)))
508+
if (
509+
prop.MemberInfo.DeclaringType == typeof(bool) || (
510+
prop.MemberInfo.DeclaringType.IsGenericType &&
511+
prop.MemberType.IsGenericType &&
512+
prop.MemberType.GetGenericTypeDefinition() == typeof(Nullable<>) &&
513+
prop.MemberInfo.DeclaringType.GetGenericArguments()[0] == typeof(bool)
514+
)
515+
)
509516
{
510517
var value = (bool?)propValue;
511518
if (!value.HasValue)

0 commit comments

Comments
 (0)