拜读websharp时,发现的几处问题(二)
4.在持久管理对象PersistanceManager.cs的实现SingleTablePM.cs文件的ExecuteNonQuery方法,在实例化参数时
仅指定对应的字段名及字段值,未指定当前参数的DbType类型,这样所有参数的类型都会默认为DbType.AnsiString
当然这在MSSqlServer里可能没问题(测试过,未发现异常),但在Oracle数据库中除字符类型外的Data,Number等都会
出错,所以此处我认为必须加入DbType类型。关于每个字段的DbType我们在生成实体时就已经存在,所以应当直接读取对应字段的DbType就可以了,由于时间关系,未去深究此种方法的实现,暂由下面代码代替实现:
1
private void ExecuteNonQuery(EntityData entity,SqlStruct sql)
2
![](https://www.cnblogs.com/Images/dot.gif)
25
26
/**/
35
private static System.Data.DbType GetDbType(Type type)
36
![](https://www.cnblogs.com/Images/dot.gif)
61![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
25
![](/Images/OutliningIndicators/None.gif)
26
![](/Images/OutliningIndicators/ContractedBlock.gif)
35
![](/Images/OutliningIndicators/None.gif)
36
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
61
![](/Images/OutliningIndicators/None.gif)
5.在SqlGenerator的实现中,oracle与SqlServer的参数形式也是不同的,有“:”与“@”之分,所以也做以修改,在抽象类SqlGenerator
根据不同数据为类型设置不同参数形式,代码如下:
在Websharp.ORM.Service项目的SqlGenerator.cs文件中修改加入如下代码:
1![](/Images/OutliningIndicators/None.gif)
2
public static string GetDataType(DatabaseProperty pp)
3
![](https://www.cnblogs.com/Images/dot.gif)
24![](/Images/OutliningIndicators/None.gif)
25
public static SqlGenerator Instance(DatabaseProperty pp)
26
![](https://www.cnblogs.com/Images/dot.gif)
33![](/Images/OutliningIndicators/None.gif)
34![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
24
![](/Images/OutliningIndicators/None.gif)
25
![](/Images/OutliningIndicators/None.gif)
26
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
33
![](/Images/OutliningIndicators/None.gif)
34
![](/Images/OutliningIndicators/None.gif)
在DefaultSqlGenerator中加入如下代码:
public static string mstr_DataType = ":";
其它参数项修改全部由此表态变量替换
parameters[i] = mstr_DataType + columns[i];