Loading

Client Object Model学习笔记

the client library uses a SQL-like programming pattern。

When you use SQL, you must:

  1. Build a SQL query, through either an ad-hoc SQL query or a stored procedure.

  2. Execute the SQL query.

  3. Read the results from SQL.

The client object model uses the same pattern as SQL. When you call a method, you are building a query with the client library. You can build queries, and they can accumulate before being executed, but you have not sent them to the server until you first load the appropriate object or property through the Load<T>(T, Expression<Func<T, Object>>[]) method (ECMAScript: load(clientObject)), and then call the ExecuteQuery() or ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler) method (ECMAScript: executeQueryAsync(succeededCallback, failedCallback)).

 

代码
using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    
class WebSiteTitle
    {
        
static void Main()
        {
            ClientContext clientContext 
= new ClientContext("http://MyServer/sites/MySiteCollection");
            Web oWebsite 
= clientContext.Web;

            clientContext.Load(oWebsite,
                w
=>w.Title);

            clientContext.ExecuteQuery();

            Console.WriteLine(oWebsite.Title);
        }
    }
}

 

 

posted @ 2010-04-09 20:10  .net's  阅读(412)  评论(0)    收藏  举报