• SharePoint中CAML使用的一些总结


    协作应用程序标记语言 (CAML) 是一种基于 XML 的语言,用于在 Windows SharePoint Services 中定义在网站和列表中使用的字段和视图。CAML 还用于在网站设置过程中定义 Windows SharePoint Services 数据库中的表。也可以对列表进行更新,在使用SharePoint Web Service的时候十分重要。详细的规范请参考http://msdn.microsoft.com/zh-cn/library/ms462365.aspx,本文列出一些常用的和重要的信息。

    1. 一些属性 

    RowLimit:<RowLimit>10</RowLimit> 查询结果的返回行限制 

    ViewFields:<ViewFields> <FieldRef Name='Title'/> <FieldRef Name='Name'/></ViewFields>查询结果要显示的字段 

     

    2. 查询条件 

    query.Query = "<Where><Eq><FieldRef Name='Status'/>" + "<Value Type='Text'>Completed</Value></Eq></Where>";

    2.1.比较操作符如下:

    Comparison Operators

    General Meaning

    Eq

    =

    Gt

    >

    Lt

    <

    Geq

    >=

    Leq

    <=

    Neq

    <>

    Contains

    Like

    IsNull

    Null

    IsNotNull

    NotNull

    BeginsWith

    Beginning with word

    DateRangesOverlap

    compare the dates in a recurring event with a specified DateTime value, to determine whether they overlap

    2.2.Or

    .<Where> <Or> <Geq><FieldRef Name='Field1'/> <Value Type='Number'>1500</Value> </Geq> <Leq> <FieldRef Name='Field2'/><Value Type='Number'>500</Value> </Leq> </Or> </Where>

    2.3.And

    <Where> <And> <BeginsWith> <FieldRef Name="Conference"/> <Value Type="Note">Morning</Value> </BeginsWith> <Contains> <FieldRef Name="Conference" /> <Value Type="Note">discussion session</Value> </Contains> </And></Where>

    2.4.Orderby

    <OrderBy>

    <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>

    </OrderBy>

    2.5.GroupBy

    <GroupBy>

    <FieldRef Name="Modified"/>

    </GroupBy>

    3.转义

    Original

    Replacement

    "

    \"

    \

    \\

    +

    \u002b

    >

    \u003e

    <

    \u003c

    '

    \u0027

     

     

     


    例:

    <FieldRef Name=\"Checkbox\"></FieldRef> <Value Type=\"bit\">1</Value>

    4.Batch

    内嵌于 HTTP 协议中,Batch 元素必须至少包含一个 Method 元素。Batch 元素允许客户端应用程序一次性向服务器传送多个命令。

    4.1.格式

     

    <Batch

    OnError = "Return" | "Continue"

    ListVersion = ""

    Version = ""

    ViewName = "">

    <Method>

    ...

    </Method>

    ...

    </Batch>

    属性

    说明

    ListVersion

    可选属性,类型为 Integer。指定列表的版本号。

    OnError

    可选。以下是可能的值:

    · Return — 在遇到第一个错误之后,停止执行任何方法。此值为默认值。

    · Continue — 在遇到错误后,继续执行后续方法。

    Version

    可选属性,类型为 String。指定正在服务器上运行的 Windows SharePoint Services 的版本号。版本号包含四个整数,格式为 N.N.N.NNNN,它们表示产品的主版本、次版本、阶段版本和增量版本。

    ViewName

    可选属性,类型为 Guid。指定视图的 GUID。

     

    4.2.Method:在批处理中用于指定 Batch 元素中的命令。 

    Method 元素是 Batch 元素所必需的

    <Method ID="Text"

    Cmd = "Text"

    ID = "Text">

    </Method>

    属性

    说明

    Cmd

    可选属性,类型为 Text。在 Web 服务中使用,指定相关命令发布到服务器以进行列表项更新。可能的值包括:

    · Delete — 删除指定项目。

    · New — 创建指定项目。

    · Update — 修改指定项目。

    ID

    必需属性,类型为 Text。自由形式标识字符串,它实际并非由服务器使用,而是返回到客户端。

    4.3. SetList:指定当前正在使用的列表。

    <SetList

    Name = "Text"

    PreserveContext = "TRUE" | "FALSE"

    Scope = "Request">

    </SetList>

    属性

    说明

    Name

    必需属性,类型为 Text。指定该列表的名称。

    PreserveContext

    可选属性,类型为 Boolean。如果为 FALSE,则实现 SetList 元素将返回数据库查询,该查询是获取显示单个列表项的表单中数据所必需的。当视图和表单位于同一页面中时,此功能非常有用。默认值为 TRUE。

    Scope

    当设置为 Request 时,此属性使整个列表可用于该页面。

    4.4. SetVar:允许在本地将页呈现到当前 XML 级别或将页全局呈现到页的上下文中设置变量。

    <SetVar

    ID = "Text"

    Name = "Text"

    Scope = "Request"

    Value = "Text">

    </SetVar>

    属性

    说明

    ID

    可选属性,类型为 Text。提供变量的 ID。

    Name

    必需属性,类型为 Text。指定变量的名称。

    Scope

    如果设置为 Request,则变量是全局变量。

    Value

    可选属性,类型为 Text。当这是一个空元素时,可用于为变量指定值。

    在下面的示例中,第一个 GetVar 元素返回“Value_2”,第二个 GetVar 元素返回“Value_1”,因为包含“Value_2”的 SetVar 元素仅适用于“Sample”元素的子级。“Value_2”在“Sample”结束标记之后超出范围。

    XML

    <SetVar Name="myVar">Value_1</SetVar>

    <Sample>

    <SetVar Name="myVar">Value_2</SetVar>

    <GetVar Name="myVar"/>

    </Sample>

    <GetVar Name="myVar"/>

    4.5.例子

    batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +

    "<Field Name='ID'>6</Field>" +

    "<Field Name='Title'>Modified sixth item</Field></Method>" +

    "<Method ID='2' Cmd='Update'><Field Name='ID'>7</Field>" +

    "<Field Name='Title'>Modified seventh item</Field></Method>" +

    "<Method ID='3' Cmd='Delete'><Field Name='ID'>5</Field>" +

    "</Method><Method ID='4' Cmd='New'>" +

    "<Field Name='Title'>Added item</Field></Method>";

    5.WSS中的各种字段类型与.NET中对应的数据类型的对照关系

    Name

    Format

    Attachments

    System.Boolean

    Boolean

    System.Boolean

    Calculated

    N/A

    Choice

    System.String

    Computed

    N/A

    Counter

    System.Int32

    CrossProjectLink

    System.Boolean

    Currency

    System.Double

    DateTime

    System.DateTime

    GridChoice

    System.String

    Guid

    System.Guid

    Integer

    System.Int32

    Lookup

    System.String

    MaxItems

    System.Int32

    ModStat

    System.Int32

    MultiChoice

    System.String

    Note

    System.String

    Number

    System.Double

    Recurrence

    System.Boolean

    Text

    System.String

    Threading

    System.String

    URL

    System.String, System.String

    User

    System.String

    作者:生鱼片
             
  • 相关阅读:
    [Agc029D]Grid game_贪心
    [Agc029C]Lexicographic constraints_进制_二分答案_贪心
    [Agc029B]Powers of two_贪心_树形dp
    [Agc029A]Irreversible operation_逆序对
    [LuoguP1074]靶形数独_搜索
    umi react处理接口请求慢的问题
    typescript-类型
    bizcharts画图遇到的几个问题
    webpack 热更新原理
    webpack配置
  • 原文地址:https://www.cnblogs.com/Areas/p/2226431.html
Copyright © 2020-2023  润新知