0

我试图使用 CAML 查询从文档库中检索文档,但此查询返回 null。请帮助解决这个问题。

SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oWebsite.Lists["SampleDocument"];

SPQuery query = new SPQuery();
query.Query = string.Format("<Where><Eq><FieldRef Name='Author' /><Value Type='Text'>Name</Value></Eq></Where>");
SPListItemCollection collListItems = oDocumentLibrary.GetItems(query);

DataTable dt = collListItems.GetDataTable();
4

1 回答 1

0

如果查询返回确切的结果,您可以签入Caml查询。Caml Designer

尝试Camlex使用 Nuget 添加 CamlexNET

using CamlexNET;
var caml = Camlex.Query().Where(x => ((string)x["Author"] == "Value").ToString();
var query = new SPQuery
{
     Query = caml,
     RowLimit = 5000
};

SPList list = web.Lists["Document"];
SPListItemCollection items = list.GetItems(query);

foreach (SPListItem itm in items)
{
   //var id = Convert.ToString(itm["ID"]);
}
于 2015-08-21T16:31:30.170 回答