From 5966fd33548435334cf9fed843282ff3cd245174 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Sun, 18 Sep 2022 15:49:08 +0800 Subject: [PATCH] Refactor the containing loop to do more than one iteration. --- IoTSharp.Extensions.EFCore/DbReaderExtensions.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/IoTSharp.Extensions.EFCore/DbReaderExtensions.cs b/IoTSharp.Extensions.EFCore/DbReaderExtensions.cs index 8f6f6e5b1..d76427aa3 100644 --- a/IoTSharp.Extensions.EFCore/DbReaderExtensions.cs +++ b/IoTSharp.Extensions.EFCore/DbReaderExtensions.cs @@ -256,7 +256,10 @@ public static async Task FirstOrDefaultAsync(this DbDataReader dr) while (await dr.ReadAsync()) { result= dr.MapObject(colMapping); - break; + if (result != null) + { + break; + } } } dr.Close(); @@ -274,7 +277,10 @@ public static T FirstOrDefault(this DbDataReader dr) while ( dr.Read()) { result = dr.MapObject(colMapping); - break; + if (result != null) + { + break; + } } } dr.Close();