使用实体框架获取项目的元数据?

发布于 2024-10-18 14:53:27 字数 737 浏览 1 评论 0原文

我正在使用 Sharepoint 2010。

我需要知道创建/版本的日期以及我的 sharepoint 列表中项目的作者/编辑者,但我没有找到将这些列与实体框架映射的解决方案。

我尝试了这种代码:

[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "tp_author", Storage = "_author", ReadOnly = true, FieldType = "User")]
public SPUser Author
{ 
    get 
    {
        return this._author;
    }
    set
    {
        if (!value.Equals(this._author))
        {
            this.OnPropertyChanging("Author", this._author);
            this._author = value;
            this.OnPropertyChanged("Author");
        }
    }
}

但是使用该代码,Sharepoint 给了我这个错误:

传输类型 Microsoft.SharePoint.SPUser 无效

我还尝试了 _author 的其他类型,但它没有改变任何内容。

有没有办法进行这种映射?

I'm working with Sharepoint 2010.

I need to know the date of creation/edition and the author/editor of items in my sharepoint's Lists, but I didn't find a solution to map these columns with Entity Framework.

I tried this kind of code :

[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "tp_author", Storage = "_author", ReadOnly = true, FieldType = "User")]
public SPUser Author
{ 
    get 
    {
        return this._author;
    }
    set
    {
        if (!value.Equals(this._author))
        {
            this.OnPropertyChanging("Author", this._author);
            this._author = value;
            this.OnPropertyChanged("Author");
        }
    }
}

But with that code, Sharepoint give me this error:

Invalid transfer type Microsoft.SharePoint.SPUser

I also tried with other types for _author, but it doesn't change anything.

Is there a way to make this mapping?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜吻♂芭芘 2024-10-25 14:53:27

SPMetal 为用户字段生成以下代码

[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedToId", FieldType="User", IsLookupId=true)]
public System.Nullable<int> AssignedToId {
    get {
        return this._assignedToId;
    }
    set {
        if ((value != this._assignedToId)) {
            this.OnPropertyChanging("AssignedToId", this._assignedToId);
            this._assignedToId = value;
            this.OnPropertyChanged("AssignedToId");
        }
    }
}

[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedTo", ReadOnly=true, FieldType="User", IsLookupValue=true)]
public string AssignedTo {
    get {
        return this._assignedTo;
    }
    set {
        if ((value != this._assignedTo)) {
            this.OnPropertyChanging("AssignedTo", this._assignedTo);
            this._assignedTo = value;
            this.OnPropertyChanged("AssignedTo");
        }
    }
}

SPMetal generates the following code for a user field

[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedToId", FieldType="User", IsLookupId=true)]
public System.Nullable<int> AssignedToId {
    get {
        return this._assignedToId;
    }
    set {
        if ((value != this._assignedToId)) {
            this.OnPropertyChanging("AssignedToId", this._assignedToId);
            this._assignedToId = value;
            this.OnPropertyChanged("AssignedToId");
        }
    }
}

[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedTo", ReadOnly=true, FieldType="User", IsLookupValue=true)]
public string AssignedTo {
    get {
        return this._assignedTo;
    }
    set {
        if ((value != this._assignedTo)) {
            this.OnPropertyChanging("AssignedTo", this._assignedTo);
            this._assignedTo = value;
            this.OnPropertyChanged("AssignedTo");
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文