简体   繁体   English

SharePoint 2010:使用SPMetal映射到图片超链接时出错

[英]SharePoint 2010: Error Mapping to Picture Hyperlink with SPMetal

Whenever I have a column of type hyperlink with the format set for pictures, I get an error whenever there is actually a value in that column. 每当我有一个超链接类型的列并为图片设置了格式时,只要该列中实际上有一个值,就会出现错误。 The exception it throws is "Specified cast is not valid". 它引发的异常是“指定的转换无效”。

My thought is that the problem is either here (the FieldType being set to Url): 我的想法是问题出在这里(FieldType设置为Url):

[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "FOO", Storage = "FOO_", FieldType = "Url")]
public string FOO
{
    get
    {
        return this._FOO;
    }
    set
    {
        if ((value != this._FOO))
        {
            this.OnPropertyChanging("FOO", this._FOO);
            this._FOO = value;
            this.OnPropertyChanged("FOO");
        }
    }
}

Or here (it being cast to a string): 或在这里(将其强制转换为字符串):

private string _FOO;

But I'd have no idea what the proper values for either of those fields should be. 但是我不知道这些字段的正确值是多少。 Any help would be greatly appreciated. 任何帮助将不胜感激。

It works whenever this field does not have data in it and I JUST used SPMetal to generate the class, so I'll get the two most obvious questions out of the way. 只要该字段中没有数据,它就可以工作,而我只是使用SPMetal生成类,所以我将解决两个最明显的问题。

Link to the answer: https://mgreasly.wordpress.com/2012/06/25/spmetal-and-workflow-associations/ 链接到答案: https : //mgreasly.wordpress.com/2012/06/25/spmetal-and-workflow-associations/

Turns out it is a known bug when mapping lists that have associated workflows. 事实证明,在映射具有关联工作流程的列表时,这是一个已知的错误。 SPMetal assigns it as a nullable integer when it's supposed to be an Object, hence the cast error. 如果应该将其作为对象,则SPMetal会将其分配为可为空的整数,因此会产生强制转换错误。

Workaround: manually edit the mappings to make the type it returns an object or ignore the column by using a parameter map. 解决方法:手动编辑映射以使其返回对象的类型,或使用参数映射忽略列。

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

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