C# 如何以编程方式阅读 SharePoint 列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/490968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 05:25:02  来源:igfitidea点击:

How do you Read SharePoint Lists Programmatically?

c#.netasp.netsharepoint

提问by Ric Tokyo

I currently use the Linq to SharePointto retrieve data from several SharePoint lists.

我目前使用Linq to SharePoint从多个 SharePoint 列表中检索数据。

This is my current preferred method of coding my way from ASP.NET and WinForms to retrieve this data.

这是我目前从 ASP.NET 和 WinForms 编码以检索此数据的首选方法。

My only issue with this project:

我对这个项目的唯一问题:

I have to manually generate the SPML file and add this to the development environment, compile it in the project, and only then I am able to use it to connect to the List.

我必须手动生成SPML文件并将其添加到开发环境中,在项目中编译它,然后我才能使用它连接到List。

This is greatfor projects that require connecting to the one and the same list always.

对于需要始终连接到同一个列表的项目非常有用。

But I am having users creating new workspaces (sites) with each its own List from which I want to retrieve data automagically (same as linq to sharepoint does, but not statically).

但是我让用户创建新的工作区(站点),每个工作区(站点)都有自己的列表,我想从中自动检索数据(与 linq to sharepoint 相同,但不是静态的)。

Can you recommend your preferred way of accessing data from several SharePoint Lists and sites in C# WinForms and/or ASP.NET outside an actual SharePoint environment where I can specify the a new source site and list at run time?

您能否推荐从 C# WinForms 和/或 ASP.NET 中的多个 SharePoint 列表和站点访问数据的首选方式,在实际 SharePoint 环境之外,我可以在运行时指定新的源站点和列表?

采纳答案by Charlie

You have several options both of which are going to require further research on your part they are:

您有多种选择,这两种选择都需要您进一步研究,它们是:

  1. Use the SharePoint object model (Microsoft.Sharepoint.dll), you must be on a PC within the SharePoint farm.
  2. Use the SharePoint web services which can be found at SiteURL/_vti_bin/ you might want to start with Lists.asmx and work from there.
  1. 使用 SharePoint 对象模型 (Microsoft.Sharepoint.dll),您必须在 SharePoint 场内的 PC 上。
  2. 使用可在 SiteURL/_vti_bin/ 中找到的 SharePoint Web 服务,您可能希望从 Lists.asmx 开始并从那里开始工作。

You are going to need some further research as I have said, but remember GIYF.

正如我所说,您将需要进一步研究,但请记住 GIYF。

回答by Ulf

I would really encourage everyone on this topic to have a look at the ado.net driver for sharepoint from bendsoft.com. It is free for developers to use and allows you to query sharepoint information using standard sql syntax and takes care of all sorts of conversion for you.

我真的鼓励有关此主题的每个人查看来自 Bendsoft.com 的 sharepoint 的 ado.net 驱动程序。它是免费供开发人员使用的,允许您使用标准 sql 语法查询共享点信息,并为您处理各种转换。

Dim conn As New SharePointConnection("Server=mysharepointserver.com;Database=sitepath;User=spuser;Password=******;")
conn.Open()
Dim cmd As New SharePointCommand("UPDATE Employees SET Salary = 3250.50 WHERE Name = 'Steve Watson'", conn)
cmd.ExecuteNonQuery()