From 3f6cc90f8f80aa42ea760f66a752e84346d3497e Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Mon, 1 Jan 2024 01:12:34 +0800 Subject: [PATCH] Handle another Jet UNION quirk with NULL values. A string value could be returned when the store and expected type is a byte --- src/EFCore.Jet.Data/JetDataReader.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/EFCore.Jet.Data/JetDataReader.cs b/src/EFCore.Jet.Data/JetDataReader.cs index 8e6f429..1fd1530 100644 --- a/src/EFCore.Jet.Data/JetDataReader.cs +++ b/src/EFCore.Jet.Data/JetDataReader.cs @@ -115,6 +115,15 @@ namespace EntityFrameworkCore.Jet.Data return checked((byte)ulongValue); if (value is decimal decimalValue) return (byte)decimalValue; + if (value is string stringvalue) + { + if (byte.TryParse(stringvalue, out var result)) + { + return result; + } + var bt = Encoding.Unicode.GetBytes(stringvalue); + if (bt.Length > 0) return bt[0]; + } return (byte)value; }