Linq to SharePoint 之 parameters的使用

网上很多Linq to sharepoint 的文章

http://bbs.winos.cn/thread-91036-1-1.html

这里不多介绍了

本文主要介绍 在linq 生成引用的文件时使用的 parameters

在使用C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/BIN下的spmetal 工具生成 列表实体文件时 会使用到 parameter 参数

例如

spmetal /web:http://localhost /parameters:parameters.xml /language:csharp /code:Entities.cs

引用parameter的xml文件 主要是因为 我们可以在这个文件中配置我想要读取的列表,如果没有添加者个参数就会将网站内所有列表和内容类型都读取出来。

parameter.xml文件的格式具体如下

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Web Class="Entities" AccessModifier="Public"
  3. xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal" >
  4. <List Name="LinqToSharePoint" Member="LinqToSharePoint">
  5. <ContentType Name="Item" Class="LinqToSharePoint">
  6. <Column Name="标题" Member="标题"/>
  7. <ExcludeOtherColumns/>
  8. </ContentType>
  9. </List>
  10. <ExcludeOtherLists/>
  11. </Web>

web 节点中的class 就是spmetal生成class文件名

list 节点就是要读取列表。

contenttype 节点读取列表的内容类型。其中name 指具体是什么内容类型

column 节点是读取的字段名称。

这些参数都设置好,就可以运行spmetal命令了。

生成的Entities.cs 文件中就只会有你需要的列表存在了。

posted @ 2011-08-31 11:13  小师傅  阅读(181)  评论(0编辑  收藏  举报