Sharepoint2010如何使用Linq to Sharepoint

1、 在http://moss:8002创建了列表如下图所示:

Sharepoint2010如何使用Linq to Sharepoint

2、 使用

SPMetal /web:http://ContosoServer/Marketing /code:MarketingSite.cs /language:csharp

这里采用:

SPMetal /web:http://moss:8002/ /code:c:\Moss2010Entities.cs /language:csharp

3、 运行CMD,输入如下:

Sharepoint2010如何使用Linq to Sharepoint

在C盘根目录下得到类:Moss2010Entities.cs

4、 打开VS2010创建Webpart解决方案,如图:

Sharepoint2010如何使用Linq to Sharepoint

5、 C#应用程序引用Microsoft.SharePoint.Linq.dll,位置位于:C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Linq.dll

Sharepoint2010如何使用Linq to Sharepoint

6、 添加刚创建的类添加刚才创建的类Moss2010Entities.cs到已经存在的项目里来

Sharepoint2010如何使用Linq to Sharepoint

7、 引用下面2个命名空间,如下图:

Sharepoint2010如何使用Linq to Sharepoint

8、 编码如下:

Sharepoint2010如何使用Linq to Sharepoint

9、 发布预览得到如下结果:

Sharepoint2010如何使用Linq to Sharepoint

相关文章:

  • 2021-10-03
  • 2021-08-30
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-06-09
猜你喜欢
  • 2022-12-23
  • 2021-10-23
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2021-05-30
相关资源
相似解决方案