devExpress中CriteriaOperator.Parse()

GroupOperator.And(new BinaryOperator(“SubCompany”, subCompany), new BinaryOperator(“Name”, actionName))

上述的CriteriaOperator,如果写成CriteriaOperator.Parse(“SubCompany=” + subCompany + ” AND Name='” + actionName + “‘”)就不行了。本来还以为是它的局限性,只能parse一个,不能parse多个criteria.后来一想,subCompany 是对象,直接.ToString()出来后拼成的sql语句当然不行,pase()方法需要的是sql string,这和BinaryOperator的重载会接受operand 2是对象是不一样的。很小的细节问题。在编程的时候,对变量到底是什么类型,函数接受的参数是什么类型,如何转换的,一定要心中有数啊。

发表回复