none
Camlex.net and Choice fields

    Question

  • H

    I needed a library that would create CAML query for me, without installing anythjing ion sharepoint Camlex.net gives me it.

    http://camlex.codeplex.com/

    Unfortunalteyy I don know how to build queries with choice fields ??

     

    lundi 26 avril 2010 11:01

Réponses

  • Yes, it will support, query should be like. It is just sample idea may not be 100% correct, You can create your self using CAMLQueryBuilder

    <Query><Where><Or><Or><Eq><FieldRef Name='a' /><Value Type='Number'>1</Value></Eq><Eq><FieldRef Name='b' /><Value Type='Number'>1</Value></Eq></Or><And><Eq><FieldRef Name='c' /><Value Type='Number'>1</Value></Eq><Eq><FieldRef Name='d' /><Value Type='Number'>5</Value></Eq></And></Or></Where></Query>


    Ashish Kanoongo, MCP, MCSD, MCTS
    • Marqué comme réponse eligio114 jeudi 29 avril 2010 21:21
    lundi 26 avril 2010 15:15

Toutes les réponses

  • anybody ?
    lundi 26 avril 2010 12:58
  • I would suggest you should use CAML query builder(http://www.u2u.be/res/Tools/CamlQueryBuilder.aspx). On this page there are basic steps how do you create CAML query using this tool. For knowing more about writing CAML check this http://www.u2u.be/Res/Article.aspx?ART=WritingCAMLQueries.

    Let me know if you need more information.


    Ashish Kanoongo, MCP, MCSD, MCTS
    lundi 26 avril 2010 13:43
  • yes , firstly I want ot create dynamic queries in code basing on request parameters

    then I want to know - does it support something like this?

     

    where (a = 1 or b = 1) and c = 1 and d=5 ?

    lundi 26 avril 2010 14:26
  • Yes, it will support, query should be like. It is just sample idea may not be 100% correct, You can create your self using CAMLQueryBuilder

    <Query><Where><Or><Or><Eq><FieldRef Name='a' /><Value Type='Number'>1</Value></Eq><Eq><FieldRef Name='b' /><Value Type='Number'>1</Value></Eq></Or><And><Eq><FieldRef Name='c' /><Value Type='Number'>1</Value></Eq><Eq><FieldRef Name='d' /><Value Type='Number'>5</Value></Eq></And></Or></Where></Query>


    Ashish Kanoongo, MCP, MCSD, MCTS
    • Marqué comme réponse eligio114 jeudi 29 avril 2010 21:21
    lundi 26 avril 2010 15:15
  • eligio,

    unfortunately I didn't see your question in time. Yes Camlex.Net was developed as tool for simplifying creation of dynamic CAML queries, i.e. queries based on query string parameters, function calls, variables, etc (in opposite to CAML query builder which creates static query for you). It is quite easy to work with choice fields in Camlex. You need to use DataTypes.Choice type from Camlex library in order to tell that your fields have Choice type:

    var q = Camlex.Query().Where(
            x => (x["a"] == (DataTypes.Choice) "1" || x["b"] == (DataTypes.Choice) "1") &&
              x["c"] == (DataTypes.Choice) "1" && x["d"] == (DataTypes.Choice) "5");
    it will produce the following CAML:

    <Query>
     <Where>
      <And>
       <And>
        <Or>
         <Eq>
          <FieldRef Name="a" />
          <Value Type="Choice">1</Value>
         </Eq>
         <Eq>
          <FieldRef Name="b" />
          <Value Type="Choice">1</Value>
         </Eq>
        </Or>
        <Eq>
         <FieldRef Name="c" />
         <Value Type="Choice">1</Value>
        </Eq>
       </And>
       <Eq>
        <FieldRef Name="d" />
        <Value Type="Choice">5</Value>
       </Eq>
      </And>
     </Where>

    You can learn more about working with Sharepoint data types in Camlex here: http://camlex.codeplex.com/documentation (see for string-based syntax)


    Blog - http://sadomovalex.blogspot.com
    Codeplex - http://camlex.codeplex.com
    samedi 22 mai 2010 19:31