BeginsWith 要素 (Query)

適用対象: SharePoint 2016 |SharePoint Foundation 2013 |SharePoint Online |SharePoint Server 2013

Text または Note フィールド型の値を保持する列の先頭にある文字列を検索します。

<BeginsWith>
  <FieldRef Name = "Field_Name"/>
  <Value Type = "Field_Type"/>
  <XML />
</BeginsWith>

要素と属性

以下のセクションで、属性、子要素、親要素について説明します。

属性

なし

子要素

親要素

Occurrences

  • 最小 : 0
  • 最大 : 制約なし

次の例では、Query プロパティに割り当てられている文字列内の BeginsWith 要素を使用して、Journal 列が "City" で始まるリスト内の項目のタイトルを返します。

SPWeb mySite = SPControl.GetContextWeb(Context);
SPList list = mySite.Lists["List_Name "];
SPQuery query = new SPQuery();
query.Query = "<Where>" +
                "<BeginsWith>" +
                  "<FieldRef Name="Journal"/>" +
                  "<Value Type="Note">City</Value>" +
                "</BeginsWith>" +
              "</Where>";
SPListItemCollection myItems = list.GetItems(query);
foreach (SPListItem item in myItems)
{
   Label1.Text += item["Title"] + "<BR>";
}

関連項目