Recently I have got an idea to implement the ADO.NET Entity Framework in SharePoint environment.
I need to workaround the thousand hundred of records to be searched,filtered and sorted.
Gone through the best practices and planning for dealing with huge data in MSDN and googled. Learner so many characteristics of BCS and Excel Services in SharePoint.
But none of these approaches were not fit into my requirement. I decided to go with my own idea and implementation.
Frankly speaking, combining the WCF,ADO.NET EF and Hosting the WCF with ADO.NET EF in SharePoint is not simple things as I thought in ASP.NET and the guidelines for the same also verily limited in forums.
Most probably, My blog will be the first one to talk[with code implementation] about all technologies said above.
Soon I update the code snippets here..
Friday, October 26, 2012
Tuesday, October 09, 2012
SharePoint Client Side Object Model
Retrieving the SharePoint List Items through Client Side Object Model(CSOM).
Below link highlights the advantages of using the client side object model in SharePoint.
http://msdn.microsoft.com/en-us/library/ff798473.aspx
Simple start up :)
add references of these two assembly files to your SharePoint project
both available on ISAPI folder of the 14 Hive.
3 columns in the SharePoint List has been mapped with one generic class.
namespace CSCOM
{
public class ListClass
{
public string _id;
public string _title;
public DateTime _publishedDate;
public string NewsID
{
set { _id= value; }
get { return _id; }
}
public DateTime PublishedDate
{
set { _publishedDate = value; }
get { return _publishedDate; }
}
public string NewsTitle
{
set { _title = value ; }
get { return _title; }
}
public ListClass()
{ }
public ListClass(string _strId, DateTime _dtPublished, string _strNewTitle)
{
NewsID= _strId;
NewsTitle = _strNewTitle;
PublishedDate = _dtPublished;
}
}
}
Retrieving the ListItem via client side object model. You need to load the list and list collection object and execute the whole context.
List cl = new List();
ClientContext context = new ClientContext(Web.Url);
List list = context.Web.Lists.GetByTitle("Your List Name");
CamlQuery q = new CamlQuery();
q.ViewXml="";
Microsoft.SharePoint.Client.ListItemCollection cols = list.GetItems(q);
context.Load(list);
context.Load(cols);
context.ExecuteQuery();
DataTable table = new DataTable();
table.Columns.Add("Id");
table.Columns.Add("Title");
table.Columns.Add("Date Published");
foreach (Microsoft.SharePoint.Client.ListItem item in cols)
{
ListClass obj = new ListClass();
obj.NewsID = item["ID"].ToString();
obj.NewsTitle = item["Title"].ToString();
obj.PublishedDate = Convert.ToDateTime(item["Date_x0020_Published"].ToString());
cl.Add(obj);
}
GridView1.DataSource = cl;
GridView1.DataBind();
Below link highlights the advantages of using the client side object model in SharePoint.
http://msdn.microsoft.com/en-us/library/ff798473.aspx
Simple start up :)
add references of these two assembly files to your SharePoint project
- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.Runtime.dll
both available on ISAPI folder of the 14 Hive.
3 columns in the SharePoint List has been mapped with one generic class.
namespace CSCOM
{
public class ListClass
{
public string _id;
public string _title;
public DateTime _publishedDate;
public string NewsID
{
set { _id= value; }
get { return _id; }
}
public DateTime PublishedDate
{
set { _publishedDate = value; }
get { return _publishedDate; }
}
public string NewsTitle
{
set { _title = value ; }
get { return _title; }
}
public ListClass()
{ }
public ListClass(string _strId, DateTime _dtPublished, string _strNewTitle)
{
NewsID= _strId;
NewsTitle = _strNewTitle;
PublishedDate = _dtPublished;
}
}
}
Retrieving the ListItem via client side object model. You need to load the list and list collection object and execute the whole context.
List
ClientContext context = new ClientContext(Web.Url);
List list = context.Web.Lists.GetByTitle("Your List Name");
CamlQuery q = new CamlQuery();
q.ViewXml="
Microsoft.SharePoint.Client.ListItemCollection cols = list.GetItems(q);
context.Load(list);
context.Load(cols);
context.ExecuteQuery();
DataTable table = new DataTable();
table.Columns.Add("Id");
table.Columns.Add("Title");
table.Columns.Add("Date Published");
foreach (Microsoft.SharePoint.Client.ListItem item in cols)
{
ListClass obj = new ListClass();
obj.NewsID = item["ID"].ToString();
obj.NewsTitle = item["Title"].ToString();
obj.PublishedDate = Convert.ToDateTime(item["Date_x0020_Published"].ToString());
cl.Add(obj);
}
GridView1.DataSource = cl;
GridView1.DataBind();
Subscribe to:
Posts (Atom)