Click here to Skip to main content
Click here to Skip to main content

SharePoint Mapper (SPMapper)

, 23 May 2014
Rate this:
Please Sign up or sign in to vote.
A SharePoint Server Object Model List Mapper to CRUD

Introduction

The CRUD action is one of the common actions to do with data. SharePoint represents 2 types of Object Model: one is Client Object Model and the other is Server Object Model and you can do CRUD via these models (according to the privilege).

The main target of this tip is announcing the first release of SPMapper. Through this component, you can work with Server Object Model & do CRUD actions as easy as drinking a glass of water.

Homepage of SPMapper and download link.

Update (05/23/2014):

Now available on Nuget:

PM > Install-Package MBS.SharePoint.Mapper

Background

It's better to know the Server Object Model.

Please read the Privacy Policy at first (It's not open source but it's free.)

Using the Code

This component allows you to work with CRUD actions, also works with attachments of a SharePoint list.

This component has an Entity Based Approach to SharePoint list .

This component allows you to work with data easily:

using Seifollahi.SPMapper;
 
public partial class SPMapprTestWebpartUserControl : UserControl
{
        protected void Page_Load(object sender, EventArgs e)
        {
                if (!IsPostBack)
                {
                    SampleMethodForSelectData();
                }
        } 
}

void SampleMethodForSelectData()
 {
   // get the SPWeb object
   var myweb = new Web(SPContext.Current.Web);
    
   // make a Mapper object
   Mapper< MyListEntityClass> myListObject = new Mapper< MyListEntityClass>(myweb);
 
 
   // get all attachments of a listitem with ID = 8
   Attachment item8_attachments = myListObject.SelectAttachment(8);
 
   // get the item with ID 8
   MyListEntityClass item8 = myListObject.Select(8);
 
   // make your SPQuery Object
   SPQuery myQry = new SPQuery{ Query = "..." };
 
   // Select your data as a list of your entity class
   List< MyListEntityClass> result = myListObject.Select(myQry);
 
   gridview1.DataSource = result;
   gridview1.DataBind(); 
 }  

To learn more about how it works and how you should code, please refer to First Version documents.

As a developer, you have the ability to customize your classes. Please read the advanced section in the first version. Also, you can work with attachment.

Points of Interest

This component also has a QueryPaging<T> class that helps you in pagination of SharePoint List Items.

Please read all documentation!

Happy Coding!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

MB Seifollahi
Software Developer 1
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 23 May 2014
Article Copyright 2014 by MB Seifollahi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid