我试图使用CAML Query从文档库中检索文档,但此查询返回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();
答案 0 :(得分:0)
如果查询返回的确切结果,您可以在Caml
中查看Caml Designer
查询。
尝试Camlex
使用Nuget
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"]);
}