Nullable ignored on AllowNull test

This commit is contained in:
2024-08-05 11:56:07 +02:00
parent 6de41e166e
commit 3921c176ce
2 changed files with 1408 additions and 1406 deletions

View File

@@ -44,6 +44,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Collections; using System.Collections;
using System.ComponentModel;
using System.Data.Common; using System.Data.Common;
using System.Data; using System.Data;
using System.Dynamic; using System.Dynamic;
@@ -4526,7 +4527,7 @@ namespace DynamORM
}); });
if (method != null) if (method != null)
ret = o.ToString().TryParseDefault<T>(defaultValue, delegate (string v, out T r) ret = o.ToString().TryParseDefault<T>(defaultValue, delegate(string v, out T r)
{ {
r = defaultValue; r = defaultValue;
return (bool)method.Invoke(null, new object[] { v, r }); return (bool)method.Invoke(null, new object[] { v, r });
@@ -4585,7 +4586,7 @@ namespace DynamORM
else if (typeof(T) == typeof(object)) else if (typeof(T) == typeof(object))
ret = (T)o; ret = (T)o;
else if (method != null) else if (method != null)
ret = o.ToString().TryParseDefault<T>(defaultValue, delegate (string v, out T r) ret = o.ToString().TryParseDefault<T>(defaultValue, delegate(string v, out T r)
{ {
r = defaultValue; r = defaultValue;
return (bool)method.Invoke(null, new object[] { v, r }); return (bool)method.Invoke(null, new object[] { v, r });
@@ -4646,7 +4647,7 @@ namespace DynamORM
param.Scale, param.Scale,
param.Precision, param.Precision,
param.Scale, param.Scale,
param.Value is byte[]? ConvertByteArrayToHexString((byte[])param.Value) : param.Value ?? "NULL", param.Value is byte[] ? ConvertByteArrayToHexString((byte[])param.Value) : param.Value ?? "NULL",
param.Value != null ? param.Value.GetType().Name : "DBNull"); param.Value != null ? param.Value.GetType().Name : "DBNull");
} }
@@ -7292,7 +7293,7 @@ namespace DynamORM
/// <returns>Result of a query.</returns> /// <returns>Result of a query.</returns>
object Scalar(); object Scalar();
#if !DYNAMORM_OMMIT_GENERICEXECUTION && !DYNAMORM_OMMIT_TRYPARSE #if !DYNAMORM_OMMIT_GENERICEXECUTION && !DYNAMORM_OMMIT_TRYPARSE
/// <summary>Returns a single result.</summary> /// <summary>Returns a single result.</summary>
/// <typeparam name="T">Type to parse to.</typeparam> /// <typeparam name="T">Type to parse to.</typeparam>
@@ -7300,7 +7301,7 @@ namespace DynamORM
/// <returns>Result of a query.</returns> /// <returns>Result of a query.</returns>
T ScalarAs<T>(T defaultValue = default(T)); T ScalarAs<T>(T defaultValue = default(T));
#endif #endif
#region From/Join #region From/Join
@@ -9679,7 +9680,7 @@ namespace DynamORM
} }
} }
#if !DYNAMORM_OMMIT_GENERICEXECUTION && !DYNAMORM_OMMIT_TRYPARSE #if !DYNAMORM_OMMIT_GENERICEXECUTION && !DYNAMORM_OMMIT_TRYPARSE
/// <summary>Returns a single result.</summary> /// <summary>Returns a single result.</summary>
/// <typeparam name="T">Type to parse to.</typeparam> /// <typeparam name="T">Type to parse to.</typeparam>
@@ -9696,7 +9697,7 @@ namespace DynamORM
} }
} }
#endif #endif
#endregion Execution #endregion Execution
@@ -11823,7 +11824,7 @@ namespace DynamORM
func(obj) : elseFunc != null ? elseFunc() : default(R); func(obj) : elseFunc != null ? elseFunc() : default(R);
} }
#if !NET6_0_OR_GREATER #if !NET6_0_OR_GREATER
/// <summary>Simple distinct by selector extension.</summary> /// <summary>Simple distinct by selector extension.</summary>
/// <returns>The enumerator of elements distinct by specified selector.</returns> /// <returns>The enumerator of elements distinct by specified selector.</returns>
/// <param name="source">Source collection.</param> /// <param name="source">Source collection.</param>
@@ -11837,7 +11838,7 @@ namespace DynamORM
if (seenKeys.Add(keySelector(element))) if (seenKeys.Add(keySelector(element)))
yield return element; yield return element;
} }
#endif #endif
} }
namespace Dynamics namespace Dynamics
@@ -13968,7 +13969,7 @@ namespace DynamORM
Column = attr; Column = attr;
if (attr != null && attr.AllowNull && Type.IsNullableType()) if (attr != null && attr.AllowNull && !Type.IsNullableType())
attr.AllowNull = false; attr.AllowNull = false;
if (property.CanRead) if (property.CanRead)
@@ -15107,7 +15108,8 @@ namespace DynamORM
public object Value { get; internal set; } public object Value { get; internal set; }
/// <summary>Gets the result.</summary> /// <summary>Gets the result.</summary>
public ValidateResult Result { get; internal set; } public ValidateResult Result { get;internal set;}
} }
} }
} }

View File

@@ -111,7 +111,7 @@ namespace DynamORM.Mapper
Column = attr; Column = attr;
if (attr != null && attr.AllowNull && Type.IsNullableType()) if (attr != null && attr.AllowNull && !Type.IsNullableType())
attr.AllowNull = false; attr.AllowNull = false;
if (property.CanRead) if (property.CanRead)