diff --git a/Apewer/Apewer.csproj b/Apewer/Apewer.csproj
index fbd845c..8385b24 100644
--- a/Apewer/Apewer.csproj
+++ b/Apewer/Apewer.csproj
@@ -7,7 +7,7 @@
Apewer
Apewer
Apewer
- 6.0.13
+ 6.0.14
diff --git a/Apewer/Json.cs b/Apewer/Json.cs
index 668ed40..d55e7dc 100644
--- a/Apewer/Json.cs
+++ b/Apewer/Json.cs
@@ -18,7 +18,7 @@ namespace Apewer
public class Json
{
-#region 配置。
+ #region 配置。
[NonSerialized]
private static bool _throw = false;
@@ -32,11 +32,11 @@ namespace Apewer
/// 当存在递归引用时候包含递归项。指定为 True 时递归项为 Null 值,指定为 False 时不包含递归项。默认值:False。
public static bool AllowRecursively { get { return _recursively; } set { _recursively = value; } }
-#endregion
+ #endregion
-#region 构造。
+ #region 构造。
-#region 基础。
+ #region 基础。
[NonSerialized]
private JToken _jtoken = null;
@@ -53,9 +53,9 @@ namespace Apewer
[NonSerialized]
private JValue _jvalue = null;
-#endregion
+ #endregion
-#region Reset
+ #region Reset
/// 重置当前对象为空。
public void Reset()
@@ -140,7 +140,7 @@ namespace Apewer
return Reset(dictionary.Origin);
}
-#endregion
+ #endregion
private void Construct(JToken jtoken = null)
{
@@ -169,9 +169,9 @@ namespace Apewer
Construct(new JObject());
}
-#endregion
+ #endregion
-#region 属性。
+ #region 属性。
/// 用于兼容 SimpleJson 的操作。
public string this[string name]
@@ -268,9 +268,9 @@ namespace Apewer
/// 实例无效。
public bool IsNull { get { return _jtoken == null; } }
-#endregion
+ #endregion
-#region Private Get
+ #region Private Get
private List PrivateGetProperties { get { return GetProperties(); } }
@@ -280,9 +280,9 @@ namespace Apewer
private List PrivateGetItems { get { return GetItems(); } }
-#endregion
+ #endregion
-#region Object : Get/Set
+ #region Object : Get/Set
/// 获取所有类型为 Property 的子项。
public List GetProperties()
@@ -681,9 +681,9 @@ namespace Apewer
return true;
}
-#endregion
+ #endregion
-#region Array
+ #region Array
/// 获取所有类型为 Value 的子项。
public List GetValues()
@@ -903,9 +903,9 @@ namespace Apewer
}
}
-#endregion
+ #endregion
-#region Property
+ #region Property
/// Json 对象实例为空。
public bool IsNone { get { return TokenType == JTokenType.None; } }
@@ -1077,11 +1077,11 @@ namespace Apewer
return true;
}
-#endregion
+ #endregion
-#region Import / Export
+ #region Import / Export
-#region From Text
+ #region From Text
/// 从 String 到 Json 的隐式转换。
///
@@ -1107,9 +1107,9 @@ namespace Apewer
}
}
-#endregion
+ #endregion
-#region From Entity
+ #region From Entity
/// 解析实现 IList 的对象为 Json 对象,失败时返回 Null。
/// 将要解析的对象。
@@ -1277,16 +1277,19 @@ namespace Apewer
}
}
- // 处理 Type 对象。
- if (value.GetType().Equals(typeof(Type)) && (previous.Count > 2))
+ if (value != null)
{
- value = ((Type)value).FullName;
- }
+ // 处理 Type 对象。
+ if (value.GetType().Equals(typeof(Type)) && (previous.Count > 2))
+ {
+ value = ((Type)value).FullName;
+ }
- // 处理 Assembly 对象。
- if (value.GetType().Equals(typeof(Assembly)) && (previous.Count > 2))
- {
- value = ((Assembly)value).FullName;
+ // 处理 Assembly 对象。
+ if (value.GetType().Equals(typeof(Assembly)) && (previous.Count > 2))
+ {
+ value = ((Assembly)value).FullName;
+ }
}
if (value == null) { json.AddItem(); }
@@ -1410,9 +1413,9 @@ namespace Apewer
}
}
-#endregion
+ #endregion
-#region To Text
+ #region To Text
/// 导出文本,可指定缩进。若类型为 String,则导出 String 值,忽略缩进。
internal static string Export(Json json, bool indented)
@@ -1444,9 +1447,9 @@ namespace Apewer
return Export(this, indented);
}
-#endregion
+ #endregion
-#region To Entity
+ #region To Entity
/// 填充类型实例,失败时返回 NULL 值。
public static T FillObject(Json json, bool ignoreCase = true, string ignoreCharacters = null, bool force = false) where T : class, new()
@@ -1691,13 +1694,13 @@ namespace Apewer
}
}
-#endregion
+ #endregion
-#endregion
+ #endregion
-#region Statics
+ #region Statics
-#region 创建实例。
+ #region 创建实例。
/// 创建新对象。
public static Json NewObject()
@@ -1861,7 +1864,7 @@ namespace Apewer
return new Json(new JProperty(name, null));
}
-#endregion
+ #endregion
/// 格式化 Json 文本。
public static string Format(string text)
@@ -1944,7 +1947,7 @@ namespace Apewer
return true;
}
-#endregion
+ #endregion
}
diff --git a/Apewer/Source/MySql.cs b/Apewer/Source/MySql.cs
index 4858acf..b74ab22 100644
--- a/Apewer/Source/MySql.cs
+++ b/Apewer/Source/MySql.cs
@@ -738,30 +738,52 @@ namespace Apewer.Source
return columns;
}
- private static string GenerateInsertStatement(string argTable, List argColumns)
+ private static string GenerateInsertStatement(string table, List columns)
{
- var result = TextUtility.EmptyString;
- var table = TextUtility.AntiInject(argTable, 255);
- if (argColumns != null && !TextUtility.IsBlank(table))
+ var sql = TextUtility.EmptyString;
+ var tn = TextUtility.AntiInject(table, 255);
+ if (columns != null && !TextUtility.IsBlank(tn))
{
- var count = argColumns.Count;
+ var count = columns.Count;
var names = new List(count);
var values = new List(count);
- foreach (var column in argColumns)
- {
- //names.Add(TextGenerator.Merge("[", column, "]"));
- names.Add(TextUtility.Merge(column));
- values.Add("@" + column);
- }
- var text = new StringBuilder();
- if (count > 0)
+ foreach (var column in columns)
{
- text.Append("insert into `", table, "`(", string.Join(", ", names), ") ");
- text.Append("values(", string.Join(", ", values), "); ");
+ if (string.IsNullOrEmpty(column)) continue;
+ names.Add($"`{column}`");
+ values.Add($"@{column}");
}
- result = text.ToString();
- }
- return result;
+
+ var ns = string.Join(", ", names);
+ var vs = string.Join(", ", values);
+
+ sql = $"insert into `{tn}` ({ns}) values ({vs}); ";
+
+ // var sb = new StringBuilder();
+ // if (columns.Count > 0)
+ // {
+ // sb.Append("insert into `");
+ // sb.Append(tn);
+ // sb.Append("` (");
+ // for (var i = 0; i < columns.Count; i++)
+ // {
+ // if (i > 0) sb.Append(", ");
+ // sb.Append("`");
+ // sb.Append(columns[i]);
+ // sb.Append("`");
+ // }
+ // sb.Append(") values (");
+ // for (var i = 0; i < columns.Count; i++)
+ // {
+ // if (i > 0) sb.Append(", ");
+ // sb.Append("@");
+ // sb.Append(columns[i]);
+ // }
+ // sb.Append("); ");
+ // }
+ // sql = sb.ToString();
+ }
+ return sql;
}
private static string GenerateUpdateStatement(TableStructure structure, string key, List columns)
diff --git a/Apewer/_ChangeLog.md b/Apewer/_ChangeLog.md
index db3a0ab..3dd4857 100644
--- a/Apewer/_ChangeLog.md
+++ b/Apewer/_ChangeLog.md
@@ -5,6 +5,10 @@
### 最新提交
+### 6.0.14
+- 修正了 Json.Parse 的 NULL 引用问题;
+- 修正了生成 MySQL 的 Insert 语句字段报错问题。
+
### 6.0.13
- 从文本转换到 Single、Double 和 Decimal,在转换前将自动修剪;
- 不再强制要求在启动 Kestrel 前调用 SetKestrelEntries。