In SharePoint 2010. NET managed client model, a simple example

Source: Internet
Author: User
Tags object model

. 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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.