Tag: caml

CAML查询到SharePoint列表返回整个集

我一直遇到一个问题,如果我在C#中执行CAML查询,我的ListItemCollection包含整个列表。 这是我擦洗代码的片段,也许你可以看到我做错了什么。 在调试时,我发现生成的XML是我从文件中读取的值所期望的。 实际执行查询和加载结果似乎存在问题。 我在这里做的步骤对我来说似乎不正确,我觉得我错过了一步。 using Microsoft.SharePoint.Client; … System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(user, password, domain); ClientContext clientContext = new ClientContext(uri); clientContext.Credentials = credentials; List list = clientContext.Web.Lists.GetByTitle(listName); //read line of input from file and save to string[] CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = “” + columns[2].Trim() + “” + columns[0].Trim() + “” + columns[1].Trim() […]

有没有办法从ListItem获取Folder对象?

我正在尝试使用客户端对象模型(.Net 4.0)在SharePoint 2010客户端应用程序中通过其路径获取Folder对象。 我需要检查库中是否存在’folderPath’变量描述的文件夹,然后获取Folder对象以进行进一步的操作。 为了提高性能,我选择使用CAML查询来过滤列表。 我的代码: IEnumerable library = this.clientContext.LoadQuery( this.clientContext.Web.Lists.Where(p => p.Title == this.documentLibrary)); this.clientContext.ExecuteQuery(); List libraryList = library.FirstOrDefault(); //code to handle libraryList == null CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = “” + “” + “” + “” + “” + “” + “1” + “” + “” + “” + “” + […]

Sharepoint的CAML查询中的日期时间比较

我正在尝试从sharepoint列表中获取某些项目,具体取决于自定义列中的日期。 我已经使用U2U Caml Builder创建了我的查询,这是有效的,但是当我把它放在我的webpart中的自己的代码中时,它总是返回给我列表中的所有项目。 这是我的代码: DateTime startDate = new DateTime(Int32.Parse(year), 1, 1); DateTime endDate = new DateTime(Int32.Parse(year), 12, 31); SPQuery q = new SPQuery(); q.Query = “” + SPUtility.CreateISO8601DateTimeFromSystemDateTime(startDate) + “” + SPUtility.CreateISO8601DateTimeFromSystemDateTime(endDate) + “”; SPListItemCollection allItem = library.GetItems(q);

使用camlQuery的Sharepoint 2010客户端对象模型 – 文件下载但没有内容/ 0字节

我正在尝试从文档库中的文件夹中的子文件夹下载txt文件。 我正在使用camlQuery来实现这一目标。 不幸的是,我没有得到txt文件的内容。 它有0个字节。 public void SaveFolderFiles(string fileName, string libraryName, ClientOM.ClientContext clientContext) { ClientOM.List sharedDocumentsList = clientContext.Web.Lists.GetByTitle(libraryName); ClientOM.CamlQuery camlQuery = new ClientOM.CamlQuery(); camlQuery.FolderServerRelativeUrl = “/Site/Folder/Folder2010/”; camlQuery.ViewXml = @” ” + fileName + @” 1 “; ClientOM.ListItemCollection listItems = sharedDocumentsList.GetItems(camlQuery); clientContext.Load(sharedDocumentsList); clientContext.Load(listItems); clientContext.ExecuteQuery(); if (listItems.Count == 1) { ClientOM.ListItem item = listItems[0]; Console.WriteLine(“FileLeafRef: {0}”, item[“FileLeafRef”]); Console.WriteLine(“FileDirRef: […]