get list items in sharepoint 2010 c# using client object model
string siteUrl = "http://sharepointsite.com/site";
ClientContext ccsite = new ClientContext(siteUrl);
ccsite.Load(ccsite.Web);
List listobj = ccsite.Web.Lists.GetByTitle("listname");
ccsite.Load(listobj);
CamlQuery qry = new CamlQuery();
qry.ViewXml = "<View/>";
ListItemCollection _icoll = listobj.GetItems(qry);
ccsite.Load(_icoll);
ccsite.ExecuteQuery();
foreach (ListItem item in _icoll)
{
string item1 = Convert.ToString(item["ColumnName"].ToString());
}
string siteUrl = "http://sharepointsite.com/site";
ClientContext ccsite = new ClientContext(siteUrl);
ccsite.Load(ccsite.Web);
List listobj = ccsite.Web.Lists.GetByTitle("listname");
ccsite.Load(listobj);
CamlQuery qry = new CamlQuery();
qry.ViewXml = "<View/>";
ListItemCollection _icoll = listobj.GetItems(qry);
ccsite.Load(_icoll);
ccsite.ExecuteQuery();
foreach (ListItem item in _icoll)
{
string item1 = Convert.ToString(item["ColumnName"].ToString());
}
Classes inside Client Object Model
In C#, comparing with the classes of Server Object Model we can see that Client Object Model have similar classes with a suffix in the namespace and no SP prefix in the class name.
For example: An SPSite in Server Object Model is represented in Client OM as Site with namespace Microsoft.SharePoint.Client.
Client Object Model
|
Server Object Model
|
Microsoft.SharePoint.Client.ClientContext
|
SPContext
|
Microsoft.SharePoint.Client.Site
|
SPSite
|
Microsoft.SharePoint.Client.Web
|
SPWeb
|
Microsoft.SharePoint.Client.List
|
SPList
|
댓글 없음:
댓글 쓰기