标签:
在程序中由xml配置而成的sql语句要转换为C#支持的sql语句
<settings>
<select> a.*</select>
<from>
(select top 1 (select COUNT(*) from OmsOrder as a left join SysState as b on (a.[State] = b.Value and b.StateType=‘StateDefault‘) where a.[State] = 0 and datediff(day,‘2016-03-25‘,a.[UpDate]) <= 0 ) as Added,(select COUNT(*) from OmsOrder as a left join SysState as b on (a.[State] = b.Value and b.StateType=‘StateDefault‘) where a.[State] = 9 and datediff(day,‘2016-03-25‘,a.[UpDate]) <= 0 ) as Passed,(select COUNT(*) from OmsOrder as a left join SysState as b on (a.[State] = b.Value and b.StateType=‘StateDefault‘) where a.[State] = -1 and datediff(day,‘2016-03-25‘,a.[UpDate]) <= 0 ) as Droped, a.* from Omsorder as a ) a
</from>
<where></where>
<orderby> a.Name desc</orderby>
</settings>
原先这里是写成大于号和小于号
程序进行转换时出错
当我们需要通过xml格式处理sql语句时,经常会用到< ,<=,>,>=等符号,但是很容易引起xml格式的错误,这样会导致后台将xml字符串转换为xml文档时报错,从而导致程序错误。
这样的问题在iBatiS中或者自定义的xml处理sql的程序中经常需要我们来处理。其实很简单,我们只需作如下替换即可避免上述的错误:
详细解释在如下路径:
http://blog.csdn.net/hu_shengyang/article/details/8513655
C#怎样处理xml文件的大于号和小于号等常用符号(xml符号引发的程序错误)
标签:
原文地址:http://www.cnblogs.com/xielong/p/5360188.html