Why do I get "not supported " exception in the 2nd block of code

Nov 16, 2012 at 8:14 AM

                        var lst2 = web.Lists["Виды документов"];
                        var nameFieldName = lst2.Fields["Название"].InternalName;
                        var name1 = "";
                        SPQuery search;
                        string caml1;

                        name1 = "Изменение банковских реквизитов контрагента";
                        caml1 = Camlex.Query().Where(x => ((string)x[nameFieldName]) == name1).ToString();

This code works fine, no run-time exceptions. But this:

                        var lst2 = web.Lists["Виды документов"];
                        var nameFieldName = lst2.Fields["Название"].InternalName;
                        var name1 = "";
                        SPQuery search;
                        string caml1;

                        name1 = "Изменение банковских реквизитов контрагента";
                        caml1 = Camlex.Query().Where(x => ((string)x[nameFieldName]).ToUpper() == name1.ToUpper()).ToString();

tells me something unclear about incorrect syntax or similar. I wonder why and how to have case-insensitive strings comparison in Camlex?

Coordinator
Nov 16, 2012 at 12:29 PM

senglory hi,

in CAML there are no options for specifying should query be case sensitive or not. Camlex is a tool which simplifies creation of CAML queries, but it doesn't extends the CAML. I.e. all limitations of CAML are still here. So your 2nd syntax is not correct.

By default CAML queries are case insensitive and you don't need to do extra steps for this. If it doesn't in your case (otherwise you would not worry about that I guess), then probably collation of your content database was changed from CI (case insensitive) to CS (case sensitive). You should investigate the reasons of this.

More often people ask how to make search via SPQuery case sensitive. In order to do that you have to retrieve items using case insensitive CAML and then additionally filter them in memory.