Accessing SharePoint data with the client model
When accessing SharePoint data with the client model, you first add two references, one is Microsoft.SharePoint.Client, and the other is Microsoft.SharePoint.Client.Runtime
In the program to reference the Microsoft.SharePoint.Client namespace
1. Here is a simple example of accessing SharePoint list data, reading the list name as a news list, where
ClientContext ct = new ClientContext ("http://moss:84");
networkcredential NW = credentialcache.defaultnetworkcredentials;
Ct. Credentials = NW;
Microsoft.SharePoint.Client.Web Web = Ct. Web;
List LST = web. Lists.getbytitle ("News list");
Camlquery camlquery = new Camlquery ();
Camlquery.viewxml = "<View/>";
Microsoft.SharePoint.Client.ListItemCollection lts = lst. GetItems (Camlquery);
Fieldcollection FLDS = lst. fields;
Ct. Load (LST);
Ct. Load (LTS);
Ct. Load (FLDS);
Ct. ExecuteQuery ();
String fName = String. Empty;
foreach (Field f in FLDS)
//{
if (F.title = = "pinned image")
// {
FName = F.internalname;
Break
// }
//}
Here is the value of the Read Spfieldurlvalue field whose value contains two values, one is the URL, and the other is the description
foreach (Microsoft.SharePoint.Client.ListItem lt in Lts)
//{
if (lt[fname]!=null)
//{
Fieldurlvalue FURL = new Fieldurlvalue ();
FURL = (fieldurlvalue) lt[fname];
Response.Write ("ID:" +i.tostring () + ", LID:" +lt. Id+ "," +furl.url);
Response.Write ("<br/>");
i++;
//}
Response.Write (Lt[fname]);
Response.Write ("<br/>");
// }
Microsoft.SharePoint.Client.ListItem lt = lts[0];
foreach (Microsoft.SharePoint.Client.Field f in FLDS)
{
Response.Write ("Field Name:" +f.title+ ": Field Intername:" +f.internalname);
Response.Write ("<br/>");
}
Access SharePoint Data Production site news list with client model