0

I'm using SPMetal to generate a class for my lists to use in a Sandbox-solution (with Sandbox Visual WebParts).

However, when I generate the classes for a list column of type "Person or Group" with display value "Name with Picture", I only get the string for that person's name back (SPMetal only generates a string property for this field).

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

Is there any way to get both the person's name and the profile picture, like it does in the default list view?

Thanks

2

i'm afraid you can't get the profile picture directly.

linq to sharepoint can retrieve only id or displayname from a User field (lookup field) by set the ColumnAttribute IsLookupValue = true or IsLookupId = true

so you can get a spuser object by the userid first, then get the profile picture.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.