2

I'm trying to use Linq to Sharepoint to get a list and i got this message:

Cannot find corresponding storage member for member Title

I've tried some solution but nothing worked. And i don't know why i have this message cause i declared the clumn title in my class. This is how my query look like

            DataContext busiSite = new DataContext(shpWeb.Url);
            EntityList<Timesheet> timesheetList = busiSite.GetList<Timesheet>("TimesheetDB");

            var currentUserTimesheet = from timesheet in timesheetList
                                       where timesheet.Author == currentUser.Name
                                       select timesheet;

I have the error on the second line EntityList<..

And i have the column Title declared in my class:

    [ContentType(Name = "TimesheetDBList", Id = "0x0100A832113A78044B63A5A4563375164A6D")]
    public partial class Timesheet
    {
    [Column(Name = "Title", FieldType = "Text")]
    public string Title { get; set; }
    [Column(Name = "JobCode", FieldType = "Text")]
    public string JobCode { get; set; }
    [Column(Name = "ClientName", FieldType = "Text")]
    public string ClientName { get; set; }
    [Column(Name = "DateMonth", FieldType = "DateTime")]
    public DateTime DateMonth { get; set; }
    [Column(Name = "Heure", FieldType = "Number")]
    public float Heure { get; set; }
    [Column(Name = "Author", FieldType = "User")]
    public string Author { get; set; }
    }

And this is my content type:

  <ContentType ID="0x0100A832113A78044B63A5A4563375164A6D" Name="TimesheetDBList" Group="Custom Content Types" Description="My Content Type" Inherits="TRUE" Version="0">
<FieldRefs>
  <!--<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" DisplayName="Title" Required="TRUE" Name="Title"/>
  <FieldRef ID="{1df5e554-ec7e-46a6-901d-d85a3881cb18}" DisplayName="Created By" Required="FALSE" Name="Author"/>-->
  <FieldRef ID="{2310b2c8-be35-4638-97e3-3d7e5e82480f}" DisplayName="Job Code" Required="FALSE" Name="JobCode" />
  <FieldRef ID="{6b5b1ca1-13fc-4eaf-b645-68235fc3466b}" DisplayName="Client Name" Required="FALSE" Name="ClientName" />
  <FieldRef ID="{6acdfb2e-9bec-445e-a01f-ac2e27d5aeb9}" DisplayName="Date" Required="FALSE" Name="DateMonth" Format="DateOnly" />
  <FieldRef ID="{81df7749-8066-4d67-915d-b9625a5c60f7}" DisplayName="Heure" Required="FALSE" Name="Heure" />
</FieldRefs>
</ContentType>

Title is the default column in my custom list i haven't change it, and created by is another sharepoint column. I've tried to declare them in my content type file but it didn't work either. So i've commented them in case you're asking.

Thank you for your attention.

ref: http://msdn.microsoft.com/en-us/library/office/ee538250(v=office.14).aspx

  • Did you ever find a solution? Having same problem. – AdamBT Apr 15 '14 at 18:09
  • No, i used CAML query instead and used the sharepoint list to make a List of my class Timesheet. Idk how to with linq. However i would like to know how to solve this bug, i've tried some "solutions" found over the internet but nothing worked. I can paste my solution to this but it isn't linq anymore. – Timon Apr 16 '14 at 7:01
1

Yes you are right ,,,

In your Linq code, you have to inherit from Item class since your content type is already inheriting from the Item Content Type.

Actually, the following is the minimum implementation for the Item class

[ContentType(Name = "Item", Id = "0x01")]
[DerivedEntityClass(Type = typeof({YourClassName}))]
public partial class Item
{
    private System.Nullable<int> _id;
    private System.Nullable<int> _version;
    private string _path;
    protected string _title;

    [Column(Name = "ID", Storage = "_id", ReadOnly = true, FieldType = "Counter")]
    public System.Nullable<int> Id
    {
        get
        {
            return this._id;
        }
        set
        {
            if ((value != this._id))
            {
                this._id = value;
            }
        }
    }

    [Column(Name = "owshiddenversion", Storage = "_version", ReadOnly = true, FieldType = "Integer")]
    public System.Nullable<int> Version
    {
        get
        {
            return this._version;
        }
        set
        {
            if ((value != this._version))
            {
                this._version = value;
            }
        }
    }

    [Column(Name = "FileDirRef", Storage = "_path", ReadOnly = true, FieldType = "Lookup", IsLookupValue = true)]
    public string Path
    {
        get
        {
            return this._path;
        }
        set
        {
            if ((value != this._path))
            {
                this._path = value;
            }
        }
    }

    [Column(Name = "Title", Storage = "_title", Required = true, FieldType = "Text")]
    public virtual string Title
    {
        get
        {
            return this._title;
        }
        set
        {
            if ((value != this._title))
            {
                this._title = value;
            }
        }
    }

}

[ContentType(Name = "Item", Id = "0x01", List = "{ListName}")]
public partial class {YourClassName}: Item
{

}

Regards ,,,

0

I ended up using SPMetal. What I noticed from the generated code is that the CustomListItem class inherits from the Item class. Since Title is part of every list item it is in the Item class.

[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "Title", Storage = "_title", Required = true, FieldType = "Text")]
    public virtual string Title
    {
        get
        {
            return this._title;
        }
        set
        {
            if ((value != this._title))
            {
                this.OnPropertyChanging("Title", this._title);
                this._title = value;
                this.OnPropertyChanged("Title");
            }
        }
    }

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.