I am trying to pull data from Content Management Document library , Äpproval Status is not a actual document library column. It was enabled through Content Management Feature....

How to i access Approval Status Value from my Event Receiver (VS2010) using SPMetal?

2 Answers 2


spmetal will not generate the _ModerationStatus field because the field is not belong to the document contenttype.

you can simply write a partial class to add a ModerationStatus property manually

public partial class YOUR_DOCUMENT_CLASS 
    private System.Nullable<SPModerationStatus> _ModerationStatus;
    [Microsoft.SharePoint.Linq.ColumnAttribute(Name = "_ModerationStatus", Storage = "_ModerationStatus", FieldType = "Choice")]
    public System.Nullable<SPModerationStatus> ModerationStatus
            return this._ModerationStatus;
            if ((value != this._ModerationStatus))
                this.OnPropertyChanging("ModerationStatus", this._ModerationStatus);
                this._ModerationStatus= value;

public enum SPModerationStatus: int {

    None = 0,

    Invalid = 1,

    Approved = 2,

    Rejected = 4,

    Pending = 8,

    Draft = 16,

    Scheduled = 32,

this code is write just now and then paste here, without any test, but i think it will works :), i have write some similar code in my project to get the author info, and works.

good luck

  • Hi Eric,thanks for the response. I'm always getting Invalid eventhough my Approval Status is Draft. Could you please guide me?
    – Jaffar
    Apr 27, 2012 at 13:53
  • Sorry Jaffar, there's some mistake, the Value property of Microsoft.SharePoint.Linq.ChoiceAttribute should be set to the _ModerationStatus field value of SPListItem, (file.Item["_ModerationStatus"]), after check the real data, i changed the SPModerationStatus in the answer
    – Eric
    Apr 28, 2012 at 6:36

You should be able to get the value out using a Parameter file for SPMetal like this:

<?xml version="1.0" encoding="utf-8"?>
<Web xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">
  <List Name="Images">
     <ContentType Name="Image" Class="ImageWithStatus">
       <Column Name="_ModerationStatus" Member="ModerationStatus" />
  <ExcludeOtherLists />

Run SPMetal like this:

SPMetal /web:http://sp2010 /parameters:param.xml /code:test.cs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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