mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 优化 Guid GetDefaultValue 可能导致的错误;
This commit is contained in:
@ -128,10 +128,14 @@ public static partial class FreeSqlGlobalExtensions
|
||||
{
|
||||
if (that == null) return null;
|
||||
if (that == typeof(string)) return default(string);
|
||||
if (that == typeof(Guid)) return default(Guid);
|
||||
if (that.IsArray) return Array.CreateInstance(that, 0);
|
||||
var ctorParms = that.InternalGetTypeConstructor0OrFirst(false)?.GetParameters();
|
||||
if (ctorParms == null || ctorParms.Any() == false) return Activator.CreateInstance(that, true);
|
||||
return Activator.CreateInstance(that, ctorParms.Select(a => a.ParameterType.IsInterface || a.ParameterType.IsAbstract || a.ParameterType == typeof(string) ? null : Activator.CreateInstance(a.ParameterType, null)).ToArray());
|
||||
return Activator.CreateInstance(that, ctorParms
|
||||
.Select(a => a.ParameterType.IsInterface || a.ParameterType.IsAbstract || a.ParameterType == typeof(string) || a.ParameterType.IsArray ?
|
||||
null :
|
||||
Activator.CreateInstance(a.ParameterType, null)).ToArray());
|
||||
}
|
||||
internal static NewExpression InternalNewExpression(this Type that)
|
||||
{
|
||||
|
Reference in New Issue
Block a user