Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linq EntityRef<;T>;问题,不从查找列表返回值_Linq_Sharepoint 2010 - Fatal编程技术网

Linq EntityRef<;T>;问题,不从查找列表返回值

Linq EntityRef<;T>;问题,不从查找列表返回值,linq,sharepoint-2010,Linq,Sharepoint 2010,好的,我会尽可能多地解释 我有一个名为EEE Content Type的站点查找列,它引用了站点内容项类型列表 现在在我的自定义列表(从项继承)中,我引用了该列,它在sharepoint fine中出现并显示查找值 问题是当我使用SPMetal.exe生成它抱怨“字典中没有密钥”的类型时失败了。因此,我删除了SPMetal的parameters.xml文件中的列定义,并重新生成了类 现在我已经手动添加了属性和关联 private EntityRef<SiteContentItemTypeI

好的,我会尽可能多地解释

我有一个名为EEE Content Type的站点查找列,它引用了站点内容项类型列表

现在在我的自定义列表(从项继承)中,我引用了该列,它在sharepoint fine中出现并显示查找值

问题是当我使用SPMetal.exe生成它抱怨“字典中没有密钥”的类型时失败了。因此,我删除了SPMetal的parameters.xml文件中的列定义,并重新生成了类

现在我已经手动添加了属性和关联

private EntityRef<SiteContentItemTypeItem> _eeeContentType;
[Association(Name = "EEE_x0020_Content_x0020_Type", Storage = "_eeeContentType", MultivalueType = AssociationType.Single, List = "Site Content Item Types")]
public SiteContentItemTypeItem EEEContentType
{
    get
    {
        return this._eeeContentType.GetEntity();
    }
    set
    {
        this._eeeContentType.SetEntity(value);
    }
}
private EntityRef\u eecontentType;
[关联(Name=“EEE\u x0020\u Content\u x0020\u Type”,Storage=“\u eeeContentType”,MultivalueType=AssociationType.Single,List=“站点内容项类型”)]
公共站点内容项类型项目EECONTENTTYPE
{
得到
{
返回此项。_eecontentType.GetEntity();
}
设置
{
此.eecontentType.SetEntity(值);
}
}
SiteContentItemTypeItem继承自项,因此其类为空

但是当我加载我创建的自定义列表时,我得到第一个条目,EEEContentType字段为空

using (IntranetDataContext context = new IntranetDataContext("http://siteurl")) {
    context.ObjectTrackingEnabled = false;

    EntityList<SiteContentItem> alerts = context.GetList<SiteContentItem>("User Alerts");
    SiteContentItem alert = (from tmpalert in alerts where tmpalert.Id == 1 select tmpalert).First();
    SiteContentItemTypeItem contentType = alert.EEEContentType;
}
使用(IntranetDataContext=新的IntranetDataContext(“http://siteurl")) {
context.ObjectTrackingEnabled=false;
EntityList警报=context.GetList(“用户警报”);
SiteContentItem警报=(从警报中的tmpalert选择tmpalert.First();
SiteContentItemTypeItemContentType=alert.EEEContentType;
}
我没有主意了

Association属性中的列表值应该是类中某个集合的列表值,还是它引用的是实际的查找列表名称?

找到了它

在通过代码创建站点查找列时,我愚蠢地“假设”SharePoint会对带有空格的字段名使用正确的命名约定

所以字段名是正确的,它的内部名称不是我所期望的。由于sharepoint linq需要内部名称,它在linq.sharepoint DLL中引发了内部异常