From 57881ad42d56512da04855f69a16c4cd2912c835 Mon Sep 17 00:00:00 2001 From: Aster <272657997@qq.com> Date: Sun, 28 Jan 2018 18:10:12 +0800 Subject: [PATCH 1/5] =?UTF-8?q?LoadFrom=20(object=20entity,=20BreakOp=20op?= =?UTF-8?q?)=20=E6=96=B9=E6=B3=95=E4=B8=AD=EF=BC=8C=E5=8F=8D=E5=B0=84?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=80=BC=E5=A4=84=E6=9C=89=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=20=E5=AF=B9=E8=B1=A1=E4=B8=8E=E7=9B=AE=E6=A0=87=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=8D=E5=8C=B9=E9=85=8D=E9=94=99=E8=AF=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=82=20?= =?UTF-8?q?=E8=AF=A5=E4=BF=AE=E6=94=B9=E4=B8=8D=E6=98=AF=E5=AE=8C=E7=BE=8E?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Table/MDataRow.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Table/MDataRow.cs b/Table/MDataRow.cs index b7aa819f..853e97ad 100644 --- a/Table/MDataRow.cs +++ b/Table/MDataRow.cs @@ -1055,6 +1055,10 @@ public void LoadFrom(object[] values) } } } + public void LoadFrom(string json) + { + LoadFrom(json, JsonHelper.DefaultEscape); + } /// /// 从json里加载值 /// @@ -1221,7 +1225,7 @@ public void LoadFrom(object entity, BreakOp op) int index = Columns.GetIndex(pi.Name); if (index > -1) { - object propValue = pi.GetValue(entity, null); + object propValue = entity.GetType().GetProperties()[index].GetValue(entity, null); switch (op) { case BreakOp.Null: From e2522ace3a55d08b49668b0dc611b6f0bedfee97 Mon Sep 17 00:00:00 2001 From: tecyang Date: Sun, 1 Apr 2018 18:45:21 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E9=9B=86=E5=90=88=E5=BA=8F=E5=88=97=E5=8C=96JSON=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E6=A0=88=E6=BA=A2=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Table/MDataRow.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Table/MDataRow.cs b/Table/MDataRow.cs index 853e97ad..ab9d214b 100644 --- a/Table/MDataRow.cs +++ b/Table/MDataRow.cs @@ -1201,12 +1201,18 @@ public void LoadFrom(object entity, BreakOp op) try { Type t = entity.GetType(); + List pis = StaticTool.GetPropertyInfo(t); if (Columns.Count == 0) { MDataColumn mcs = TableSchema.GetColumns(t); MCellStruct ms = null; for (int i = 0; i < mcs.Count; i++) { + if (mcs[i].SqlType == SqlDbType.Variant) + { + pis.Remove(t.GetProperty(mcs[i].ColumnName)); + continue; + } ms = mcs[i]; MDataCell cell = new MDataCell(ref ms); Add(cell); @@ -1217,7 +1223,7 @@ public void LoadFrom(object entity, BreakOp op) { TableName = t.Name; } - List pis = StaticTool.GetPropertyInfo(t); + if (pis != null) { foreach (PropertyInfo pi in pis) @@ -1246,6 +1252,7 @@ public void LoadFrom(object entity, BreakOp op) continue; } break; + } Set(index, propValue);//它的状态应该值设置,改为1是不对的。 } From 7669ea4fe65bd3b8a68b0c43e036ae78bf94044d Mon Sep 17 00:00:00 2001 From: tecyang Date: Sun, 1 Apr 2018 18:55:24 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E9=9B=86=E5=90=88=E5=BA=8F=E5=88=97=E5=8C=96JSON=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E6=A0=88=E6=BA=A2=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CYQ.Data.csproj | 3 +-- Table/MDataRow.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CYQ.Data.csproj b/CYQ.Data.csproj index f1752e3d..6d1356dd 100644 --- a/CYQ.Data.csproj +++ b/CYQ.Data.csproj @@ -139,6 +139,7 @@ + @@ -198,8 +199,6 @@ Code - - Code diff --git a/Table/MDataRow.cs b/Table/MDataRow.cs index 853e97ad..ab9d214b 100644 --- a/Table/MDataRow.cs +++ b/Table/MDataRow.cs @@ -1201,12 +1201,18 @@ public void LoadFrom(object entity, BreakOp op) try { Type t = entity.GetType(); + List pis = StaticTool.GetPropertyInfo(t); if (Columns.Count == 0) { MDataColumn mcs = TableSchema.GetColumns(t); MCellStruct ms = null; for (int i = 0; i < mcs.Count; i++) { + if (mcs[i].SqlType == SqlDbType.Variant) + { + pis.Remove(t.GetProperty(mcs[i].ColumnName)); + continue; + } ms = mcs[i]; MDataCell cell = new MDataCell(ref ms); Add(cell); @@ -1217,7 +1223,7 @@ public void LoadFrom(object entity, BreakOp op) { TableName = t.Name; } - List pis = StaticTool.GetPropertyInfo(t); + if (pis != null) { foreach (PropertyInfo pi in pis) @@ -1246,6 +1252,7 @@ public void LoadFrom(object entity, BreakOp op) continue; } break; + } Set(index, propValue);//它的状态应该值设置,改为1是不对的。 } From eb629d000281cc32a17fe4ae10b0246bf329c9e2 Mon Sep 17 00:00:00 2001 From: tecyang Date: Sun, 1 Apr 2018 18:55:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E9=9B=86=E5=90=88=E5=BA=8F=E5=88=97=E5=8C=96JSON=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E6=A0=88=E6=BA=A2=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CYQ.Data.csproj | 3 +-- Table/MDataRow.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CYQ.Data.csproj b/CYQ.Data.csproj index f1752e3d..6d1356dd 100644 --- a/CYQ.Data.csproj +++ b/CYQ.Data.csproj @@ -139,6 +139,7 @@ + @@ -198,8 +199,6 @@ Code - - Code diff --git a/Table/MDataRow.cs b/Table/MDataRow.cs index 853e97ad..ab9d214b 100644 --- a/Table/MDataRow.cs +++ b/Table/MDataRow.cs @@ -1201,12 +1201,18 @@ public void LoadFrom(object entity, BreakOp op) try { Type t = entity.GetType(); + List pis = StaticTool.GetPropertyInfo(t); if (Columns.Count == 0) { MDataColumn mcs = TableSchema.GetColumns(t); MCellStruct ms = null; for (int i = 0; i < mcs.Count; i++) { + if (mcs[i].SqlType == SqlDbType.Variant) + { + pis.Remove(t.GetProperty(mcs[i].ColumnName)); + continue; + } ms = mcs[i]; MDataCell cell = new MDataCell(ref ms); Add(cell); @@ -1217,7 +1223,7 @@ public void LoadFrom(object entity, BreakOp op) { TableName = t.Name; } - List pis = StaticTool.GetPropertyInfo(t); + if (pis != null) { foreach (PropertyInfo pi in pis) @@ -1246,6 +1252,7 @@ public void LoadFrom(object entity, BreakOp op) continue; } break; + } Set(index, propValue);//它的状态应该值设置,改为1是不对的。 } From e607f761149d25a6a3ec4581fe6c8221cb388b4c Mon Sep 17 00:00:00 2001 From: tecyang Date: Sun, 1 Apr 2018 19:24:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E9=9B=86=E5=90=88=E5=BA=8F=E5=88=97=E5=8C=96JSON=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E6=A0=88=E6=BA=A2=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CYQ.Data.csproj | 3 +-- Table/MDataRow.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CYQ.Data.csproj b/CYQ.Data.csproj index f1752e3d..6d1356dd 100644 --- a/CYQ.Data.csproj +++ b/CYQ.Data.csproj @@ -139,6 +139,7 @@ + @@ -198,8 +199,6 @@ Code - - Code diff --git a/Table/MDataRow.cs b/Table/MDataRow.cs index 853e97ad..ab9d214b 100644 --- a/Table/MDataRow.cs +++ b/Table/MDataRow.cs @@ -1201,12 +1201,18 @@ public void LoadFrom(object entity, BreakOp op) try { Type t = entity.GetType(); + List pis = StaticTool.GetPropertyInfo(t); if (Columns.Count == 0) { MDataColumn mcs = TableSchema.GetColumns(t); MCellStruct ms = null; for (int i = 0; i < mcs.Count; i++) { + if (mcs[i].SqlType == SqlDbType.Variant) + { + pis.Remove(t.GetProperty(mcs[i].ColumnName)); + continue; + } ms = mcs[i]; MDataCell cell = new MDataCell(ref ms); Add(cell); @@ -1217,7 +1223,7 @@ public void LoadFrom(object entity, BreakOp op) { TableName = t.Name; } - List pis = StaticTool.GetPropertyInfo(t); + if (pis != null) { foreach (PropertyInfo pi in pis) @@ -1246,6 +1252,7 @@ public void LoadFrom(object entity, BreakOp op) continue; } break; + } Set(index, propValue);//它的状态应该值设置,改为1是不对的。 }