. NET Managed client model (SHAREPOINT2010) is the three client model launched by the ". NET managed, "ECMAScript", "sliverlight", compared to the script's client object model, The. NET client object model used in VS is used, a lot of convenience, at least when the writing will be prompted, compile when there will be error prompts, and then we can put the corresponding two DLL files, and write the program together, put on the client implementation, the feeling is still harvested.
Below is a description of. NET managed use, first create a new console program, select. Net3.5 framework, and then add the client references we need in the reference, located in/ Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll under the ISAPI, finally, we can write our. NET managed client object by referencing the header file we need in the head using. Model Code.
Talk about your own understanding of this client object model, feel. NET object model or SharePoint is very close to, not only to write up relatively ECMAScript convenient, and easier to master, especially convenient for us to write some gadgets, list operations, do not have to run on the server side, or to improve.
My example is still an example of reading SharePoint2010 list data, there are improper use of the place, you are welcome to correct.
static void Main (string[] args)
{
ClientContext context = new ClientContext ("http://sharepoint2010:10086/");
Web Web = context. Web;
The list List = Web. Lists.getbytitle ("myfirstlists");
Camlquery query = new Camlquery ();
Query. ViewXml = @ "<view><query></query></view>";
ListItemCollection ListItem = list. GetItems (query);
Context. Load (ListItem);
Context. Load (web);
Context. Load (list);
Context. ExecuteQuery ();
String title = web. Title;
String listname = list. Title;
Console.WriteLine ("Website name:" + title);
Console.WriteLine ("List name:" +listname);
Console.WriteLine ("List data:");
foreach (ListItem list2 in ListItem)
{
Console.WriteLine (list2["Title"]. ToString ());
}
As with the ECMAScript client object model, the program does not request data at load time, but actually initiates the request at ExecuteQuery. Next, give you a few of my reference links:
Accessing SharePoint 2010 Data using the. NET Client Object Model
Http://msdn.microsoft.com/zh-cn/library/gg277498.aspx
SharePoint2010. NET Client Object Model class library
Http://msdn.microsoft.com/en-us/library/ee536622.aspx
Author: Lin Yu
Source: Http://www.cnblogs.com/jianyus
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/web/sharepoint/