多种CAML条件的查询

在编程过程中经常遇到很多情况的CAML语句查询,下面就一一来整理下

单个CAML条件查询

                                 "<Query>" +
                                            "<Where>" +
                                                "<Eq>" +
                                                    "<FieldRef Name='RecordId' />" +
                                                    "<Value Type='Text'>" + procurementRecordId + "</Value>" +
                                                "</Eq>" +
                                            "</Where>" +
                                        "</Query>" +

其中RecordId 列表名,procurementRecordId为变量名

两个CAML 条件查询

           "<Query>" +
                         "<Where>" +
                            "<And>" +
                                "<Eq><FieldRef Name='RecordId' /><Value Type='Text'>" + id + "</Value></Eq>" +
                                "<Eq><FieldRef Name='WorkflowId' /><Value Type='Text'>" + flowID + "</Value></Eq>" +
                            "</And>" +
                         "</Where>" +
                     "</Query>" +


可以注意到的是当一个的时候不需要AND来拼接当有两个的时候必须要有个And来拼接


三个CAML条件的查询

 "<Query>" +
                         "<Where>" +
                            "<And>" +
                            "<And>" +
                                "<Eq><FieldRef Name='RecordId' /><Value Type='Text'>" + id + "</Value></Eq>" +     
                                "<Eq><FieldRef Name='WorkflowId' /><Value Type='Text'>" + flowID + "</Value></Eq>" +
                                 "</And>" +
                                "<Eq><FieldRef Name='flag'/><Value Type='Text'>1</Value></Eq>" +
                            "</And>" +
                         "</Where>" +
                     "</Query>" +


三个CAML 查询的时候And一定要打对地方

首先是有这样的规律有几个查询就在开头写2个And,然后再第二个条件间加个</And>




阅读更多
个人分类: 解决的问题
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

多种CAML条件的查询

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭