简体   繁体   English

使用SPMetal为Sharepoint中的网站集生成LINQ类

[英]Generate LINQ classes with SPMetal for Site Collection in Sharepoint

I try to generate LINQ classes for my Site Collection root in Sharepoint with this command (all in one line): 我尝试使用此命令在Sharepoint中为我的Site Collection根生成LINQ类(全部在一行中):

SPMetal.exe
/web:http://myserver 
/namespace:mynamespace 
/code:myfile.cs 
/parameters:mysettings.xml

The mysettings.xml looks like this: mysettings.xml看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal"
 xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">
    <List Name="List1"/>
    <List Name="List2"/>
    <ExcludeOtherLists/>
</Web>

But it doesn't work, the resulting error is (roughly translated from German): 但它不起作用,产生的错误(大致翻译自德语):

The specified file name can not be used. 无法使用指定的文件名。 Perhaps already a file or directory with this name exists, or permissions are not sufficient to access the file. 可能已存在具有此名称的文件或目录,或者权限不足以访问该文件。

And I think it can't be a file problem because: 我认为这不是一个文件问题,因为:

  1. If I change the web URL to http://myserver/subsite it works pretty good, the file gets generated 如果我将网址更改为http://myserver/subsite它的效果非常好,会生成文件
  2. I can see the file being created with 0kb and after 1-2 seconds the file gets deleted and the error message is shown 我可以看到使用0kb创建的文件,1-2秒后文件被删除并显示错误消息
  3. I have more than enough space and permissions are ok as well (see 1.) 我有足够的空间和权限也可以(参见1.)

So what am I missing? 那我错过了什么? Or can't I create LINQ classes for the root Site Collection? 或者我不能为根网站集创建LINQ类?

If you are using Visual Studio 2010 try LINQ to SharePoint extension . 如果您使用的是Visual Studio 2010,请尝试LINQ to SharePoint扩展 It allows to use nice UI wizard for generating models classes. 它允许使用漂亮的UI向导来生成模型类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM