Friday 12 June 2015

CAML Query with more than two conditions

Below is a CAML Query to fetch the records of  the employees with employee Id 313765, 313766, 313767 and ManagerId equal to 212345 and Their Salary should be greater than 20000.


query = @"<View Scope='RecursiveAll'>"

                        + "<Query>"

                            + "<Where>"

                                + "<And>"

                                    + "<And>"

                                        + "<In>"

                                            + "<FieldRef Name='EmpId' />"

                                                + "<Values>"

                                                    + "<Value Type='Text'>" + "313765" + "</Value>"

                                                    + "<Value Type='Text'>" + "313766"+ "</Value>"

                                                    + "<Value Type='Text'>" + "313767" + "</Value>"

                                                + "</Values>"

                                        + "</In>"

                                    + "<Eq><FieldRef Name='ManagerId' /><Value Type='Text'>" + "212345" + "</Value></Eq>"

                                    + "</And>"

                                + "<Geq><FieldRef Name='Salary' /><Value Type='Number'>" + "20000" + "</Value></Geq>"

                                + "</And>"

                            + "</Where>"

                        + "</Query>"

                    + "</View>";

No comments: