For a reason I don’t know, when you try to generate entity classes for your sharepoint site, SPMetal doesn’t generate property for Publishing field.
Imagine a field declare like that :
<Field ID="{B126F0CB-C1C3-476E-A499-80528707A784}" Name="Comments" DisplayName="Comments" Type="HTML" RichText="TRUE" RichTextMode="FullHtml" Required="TRUE" />
Here is a solution to this problem. Create a partial class for accessing your list and add manually a property like this :
public partial class MyClassCT
{
private string _comments;
[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "Comments", Storage = "_comments", FieldType = "Text")]
public string Comments
{
get { return _comments; }
set
{
if ((value != this._comments))
{
this.OnPropertyChanging("Comments", this._comments);
this._comments= value;
this.OnPropertyChanged("Comments");
}
}
}
}
As you can see, I declare the fieldtype as Text and so, the property can be a simple string.
That’s it, you can now access the property like any others.
This works very well for reading, but when you try to create or update the list, you would get this error :
Incompatible column types. Previous type: Text . Current type: Invalid.
After some research, I can’t find which type should be use. I try FieldType = “Invalid” and …, it works.
Here is the column attribute definition :
[ColumnAttribute(Name = "Comments", Storage = "_comments", FieldType = "Invalid")]
There is some things I don’t understand. If someone can explain me why Invalid is considered as a good value, I would be very grateful !
NB : your field must be declare as HTML is the schema.xml.