sharepoint - 使用 Sharepoint 2010 Client OM 指定要加载的项目字段

标签 sharepoint object model client

使用客户端 OM 查询列表时,如何动态生成/指定要加载的项目字段列表?

这可以在 CAML 查询上使用标签来完成,但这会加载额外的不需要的字段,从而使有效负载更大。看这里:http://blogs.technet.com/b/speschka/archive/2009/11/01/using-the-sharepoint-2010-client-object-model-part-3.aspx

这是我使用的测试代码:

    ClientContext clientContext = new ClientContext("http://myserver/sites/mysite");
Web site = clientContext.Web;

List list = clientContext.Web.Lists.GetByTitle("MyList");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View Scope='RecursiveAll'><RowLimit>100</RowLimit></View>";
ListItemCollection listItems = list.GetItems(camlQuery);

clientContext.Load(listItems,
      items => items.ListItemCollectionPosition,
      items => items.Include(
              item => item["ID"],
              item => item["Title"]
              ));

clientContext.ExecuteQuery();

我想要做的是在运行时为 Include 方法生成 lambda 表达式。仍然没有运气。我尝试的每个解决方案都给我错误“不支持查询表达式”。

最佳答案

您可以使用稍后要查询的列创建特定 View ,并在调用 GetItems 方法时使用该 View 。

关于sharepoint - 使用 Sharepoint 2010 Client OM 指定要加载的项目字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11110094/

相关文章:

sharepoint - WebEx WebOffice的开源替代品?

jQuery - 使用每个对象创建一个对象数组

javascript - ExtJS 4 : Write nested XML with model associations

c# - MVC4中两个变量的RequiredIf条件验证

php - 将 Outlook 日历集成到网站/其他

sharepoint - 在 Sharepoint 中存储应用程序特定的配置数据?

php - 确定哪些对象链接或不链接到主根对象

c++ - 基本成员初始化与在类声明中分配默认值

ruby-on-rails - Rails find_or_create_by 多个属性?

sharepoint - 要下载的 Web 部件和产品文件?