From 5ccdc259c6fee4c18869f1e72ef50bc6fcc478fc Mon Sep 17 00:00:00 2001
From: zqlovejyc <943620963@qq.com>
Date: Sat, 10 Jul 2021 15:31:56 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Extensions/ObjectExtensions.cs | 36 +++++++------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/SQLBuilder.Core/Extensions/ObjectExtensions.cs b/SQLBuilder.Core/Extensions/ObjectExtensions.cs
index 6b25401..a6b90af 100644
--- a/SQLBuilder.Core/Extensions/ObjectExtensions.cs
+++ b/SQLBuilder.Core/Extensions/ObjectExtensions.cs
@@ -128,10 +128,8 @@ public static class ObjectExtensions
/// object对象
/// type
/// object
- public static object ToSafeValue(this object @this, Type type)
- {
- return @this == null ? null : Convert.ChangeType(@this, type.GetCoreType());
- }
+ public static object ToSafeValue(this object @this, Type type) =>
+ @this == null ? null : Convert.ChangeType(@this, type.GetCoreType());
#endregion
#region IsNull
@@ -140,10 +138,8 @@ public static object ToSafeValue(this object @this, Type type)
///
/// object对象
/// bool
- public static bool IsNull(this object @this)
- {
- return @this == null || @this == DBNull.Value;
- }
+ public static bool IsNull(this object @this) =>
+ @this == null || @this == DBNull.Value;
#endregion
#region IsNotNull
@@ -152,10 +148,8 @@ public static bool IsNull(this object @this)
///
/// object对象
/// bool
- public static bool IsNotNull(this object @this)
- {
- return !@this.IsNull();
- }
+ public static bool IsNotNull(this object @this) =>
+ !@this.IsNull();
#endregion
#region ToJson
@@ -164,10 +158,8 @@ public static bool IsNotNull(this object @this)
///
/// 待序列化的对象
/// string
- public static string ToJson(this object @this)
- {
- return JsonConvert.SerializeObject(@this);
- }
+ public static string ToJson(this object @this) =>
+ JsonConvert.SerializeObject(@this);
///
/// 对象序列化为json字符串
@@ -175,10 +167,8 @@ public static string ToJson(this object @this)
/// 待序列化的对象
/// JsonSerializerSettings配置
///
- public static string ToJson(this object @this, JsonSerializerSettings settings)
- {
- return JsonConvert.SerializeObject(@this, settings ?? new JsonSerializerSettings());
- }
+ public static string ToJson(this object @this, JsonSerializerSettings settings) =>
+ JsonConvert.SerializeObject(@this, settings ?? new JsonSerializerSettings());
///
/// 对象序列化为json字符串
@@ -252,10 +242,8 @@ public static T To(this object @this)
/// 实体Type类型
/// 仓储
///
- public static string ToColumns(this Type @this, IRepository repository)
- {
- return @this.ToColumns(repository.IsEnableFormat, repository.DatabaseType);
- }
+ public static string ToColumns(this Type @this, IRepository repository) =>
+ @this.ToColumns(repository.IsEnableFormat, repository.DatabaseType);
///
/// 根据实体类型获取所有列的查询字符串