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.
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()
{
var myweb = new Web(SPContext.Current.Web);
Mapper< MyListEntityClass> myListObject = new Mapper< MyListEntityClass>(myweb);
Attachment item8_attachments = myListObject.SelectAttachment(8);
MyListEntityClass item8 = myListObject.Select(8);
SPQuery myQry = new SPQuery{ Query = "..." };
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!