2013년 1월 27일 일요일

Get all the views for the SharePoint 2010 list using Client Object Model

Get all the views for the SharePoint 2010 list using Client Object Model




To create list items, you create a ListItemCreationInformation object, set its properties, and pass it as parameter to the AddItem(ListItemCreationInformation) method of theList class. Set properties on the list item object that this method returns, and then call the Update() method, as seen in the following example.
using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    class CreateListItem
    {
        static void Main()
        {   
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");

            ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
            ListItem oListItem = oList.AddItem(itemCreateInfo);
            oListItem["Title"] = "My New Item!";
            oListItem["Body"] = "Hello World!";

            oListItem.Update();

            clientContext.ExecuteQuery(); 
        }
    }
}
Because the previous example creates a standard list item, you do not need to set properties on the ListItemCreationInformation object before it is passed to theAddItem(ListItemCreationInformation) method. However, if your code must create a new folder, for example, you must set the UnderlyingObjectType of theListItemCreationInformation to Folder.
For information and an example about how to create a list item object within the context of the Microsoft SharePoint Foundation 2010 Silverlight object model, see Using the Silverlight Object Model.
To set most list item properties, you can use a column indexer to make an assignment, and call the Update() method so that changes will take effect when you callExecuteQuery() or ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler). The following example sets the title of the third item in the Announcements list.
using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    class UpdateListItem
    {
        static void Main()
        {   
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");
            ListItem oListItem = oList.Items.GetById(3);

            oListItem["Title"] = "My Updated Title.";

            oListItem.Update();

            clientContext.ExecuteQuery(); 
        }
    }
}
To delete a list item, call the DeleteObject() method on the object. The following example uses the GetItemById() method to return the second item from the list, and then deletes the item.
SharePoint Foundation 2010 maintains the integer IDs of items within collections, even if they have been deleted. So, for example, the second item in a list might not have 2 as its identifier. A ServerException is returned if the DeleteObject() method is called for an item that does not exist.
using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    class DeleteListItem
    {
        static void Main()
        {   
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");
            ListItem oListItem = oList.GetItemById(2);

            oListItem.DeleteObject();

            clientContext.ExecuteQuery(); 
        }
    }
}
If you want to retrieve, for example, the new item count that results from a delete operation, include a call to the Update() method to refresh the list. In addition, you must load either the list object itself or the ItemCount property on the list object before executing the query. If you want to retrieve both a start and end count of the list items, you must execute two queries and return the item count twice, as shown in the following modification of the previous example.
using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    class DeleteListItemDisplayCount
    {
        static void Main()
        {   
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");

            clientContext.Load(oList,
                list => list.ItemCount);

            clientContext.ExecuteQuery();

            int startCount = oList.ItemCount;
            ListItem oListItem = oList.GetItemById(2);

            oListItem.DeleteObject();

            oList.Update();

            clientContext.Load(oList,
                list => list.ItemCount);

            clientContext.ExecuteQuery();

            int endCount = oList.ItemCount;

            Console.WriteLine("Start: {0}  End: {1}", startCount, endCount);
        }
    }
}


http://msdn.microsoft.com/en-us/library/ee539976(v=office.14).aspx




In this article we are going to see how to create, update and delete SharePoint 2010 list items using Client Object Model.

I have created one list named as Test in the SharePoint 2010 site with one column "Title". I will be creating Console Application using Visual Studio 2010 to do create, update and delete methods.

Create List Item:
  • Go to Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application and name it as CreateListItem.
  • Click Add.
  • Add the references Microsoft.SharePoint.dll and Microsoft.SharePoint.Client.dll.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Client;namespace CreateListItem
    {
        class Program    {
            static void Main(string[] args)
            {
                string siteUrl = "http://servername:39130/";
                ClientContext clientContext = new ClientContext(siteUrl);
                List oList = clientContext.Web.Lists.GetByTitle("Test");
                ListItemCreationInformation listCreationInformation = newListItemCreationInformation();
                ListItem oListItem = oList.AddItem(listCreationInformation);
                oListItem["Title"] = "Item1";
                oListItem.Update();
                clientContext.ExecuteQuery();
            }
        }
    }
  • Hit F5.
  • Go to the SharePoint list "Test" and you could see a new item is added.

    1.gif
Update List Item:
  • Go to Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application and name it as UpdateListItem.
  • Click Add.
  • Add the references Microsoft.SharePoint.dll and Microsoft.SharePoint.Client.dll.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Client;
    namespace
     UpdateListItem
    {
        class Program    {
            static void Main(string[] args)
            {
                string siteUrl = "http://servername:39130/";
                ClientContext clientContext = new ClientContext(siteUrl);
                List oList = clientContext.Web.Lists.GetByTitle("Test");
                ListItem oListItem = oList.GetItemById(5);
                oListItem["Title"] = "My Updated Item.";
                oListItem.Update();
                clientContext.ExecuteQuery();
            }
        }
    }
  • Hit F5.
  • Go to the SharePoint list "Test" and you could see a item is updated.
Delete List Item:
  • Go to Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application and name it as DeleteListItem.
  • Click Add.
  • Add the references Microsoft.SharePoint.dll and Microsoft.SharePoint.Client.dll.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Client;
    namespace
     UpdateListItem
    {
        class Program    {
            static void Main(string[] args)
            {
                string siteUrl = "http://servername:39130/";
                ClientContext clientContext = new ClientContext(siteUrl);
                List oList = clientContext.Web.Lists.GetByTitle("Test");
                ListItem oListItem = oList.GetItemById(5);         
                oListItem.DeleteObject();
                clientContext.ExecuteQuery();
            }
        }
    }
  • Hit F5.
  • Go to the SharePoint list "Test" and you could see a new item is added.
http://www.c-sharpcorner.com/uploadfile/anavijai/how-to-createupdatedelete-sharepoint-2010-list-items-using-client-object-model/

SharePoint Client Object Model Redistributable Released

SharePoint Client Object Model Redistributable Released


Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.Silverlight.dll
Microsoft.SharePoint.Client.Silverlight.Runtime.dll


쉐어포인트 참조해야 할 파일은 2개
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll

경로는 쉐어포인트 설치후 
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI
경로 또는 Sharepoint 관련 setup 파일을 설치하여 dll을 추출한다.



Microsoft has released the SharePoint Foundation 2010 Client Object Model Redistributable. The assemblies for the .NET and Silverlight versions  of the SharePoint client object model are included. 
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.Silverlight.dll
Microsoft.SharePoint.Client.Silverlight.Runtime.dll
The installer deploys these to the C:\Program Files\Common Files\Microsoft Shared\SharePoint Client folder of the development computer. (There are versions for 64-bit and x86 client computers.) In addition, resource assemblies are deployed to a subfolder named with the culture ID.
The redistributable package must be installed on any client machine where your .NET client application is installed. You can either give users instructions on where to obtain it or you can include the redistributable in your installation package. This insures that the redistributable can participate in Windows Update and that each client computer has a legal copy of the assemblies. Some installation technologies enable you to call the redistributable's MSI file so the installation of the SharePoint .NET client assemblies and your application is seamless. SharePoint client assemblies obtained in other ways cannot be legally redistributed.
You may distribute the assemblies for the Silverlight version along with a solution that targets them. They can be encased inside the Silverlight xap file. Alternatively, your solution can reference the Microsoft.SharePoint.Client.xap located on every SharePoint server in the SharePoint root: ...14\TEMPLATE\LAYOUTS\ClientBin folder.  It is also possible to cache the Silverlight assemblies. They are located in that same folder.
Note that the third version of the SharePoint client object model, the JavaScript/JScript version, is defined in *.js files. These, of course, are downloaded to client computer when a SharePoint page that references them is opened. The default SharePoint master page references these files. Unless your solution includes a custom master page, you do not need to reference them in your own custom pages.



http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2010/11/18/sharepoint-client-object-model-redistributable-released.aspx

get list items in sharepoint 2010 c# using client object model

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());
}


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


mcp dump study 사이트

mcp dump study 사이트


Microsoft Exam 70-486 Study Guide

Hello all.  Recently, I wrote a study guide for the 70-480 exam (Programming in HTML5 with JavaScript and CSS3).  I wanted to follow that up with another study guide for 70-486: Developing ASP.NET MVC 4 Web Applications.  The material and sections contained in this post were retrieved from the Microsoft | Learning site: Exam 70-486 - Developing ASP.NET MVC 4 Web Applications.
I apologize, but the skills measured sections for 70-486 contain some sections that are more conceptual than focused on a particular technology in the ASP.NET MVC stack, so this post is not as robust (in terms of external links) as the last post.  For some sections, I broke down the conceptual sections into “talking points” that I could then link to research information for.  I will list these parts throughout the blog and mark them with “Talking Points” sections.  The idea is that you should be able to actually talk for a minute or so to each of these points to display that you are comfortable with conceptualizing and architecting solutions regarding the subject matter.
  

Exam Overview


So I will start off by saying that I found this test to be way more difficult than 70-480.  I passed on the first try, but barely skated by with a 718 / 1000 (passing is 700 / 1000).  I spoke to a colleague that works extensively with MVC and he too had difficulty with the test.  Just be warned that this is something you will most definitely want to study for.  Beyond this blog post, I strongly recommend the following resources (some cost money) for a more general overview of the concepts you will be tested on.
  
The Plural Sight training was helpful for the test, but would also be extremely helpful if you currently work with, or plan to work with MVC in the future.  The benefits outweigh the cost.  Worst case scenario, if you can get in on a free retake promo, you could take the test and if you fail, come back later and go through the Plural Sight training before you test again.
  

Training for the Test

Between the Plural Sight videos, the ASP.NET MVC 4 Tutorials, and the topics discussed below, I logged about 35 hours in overall study time.  I will admit that I have never actually worked with MVC 4, but I did build several projects a while back in the initial version of MVC that was released way back when.  I also keep up-to-date on the topic by reading wisdom provided by several awesome bloggers, such as Phil Haack, Scott Hanselman, Gu, and many others.
  

Testing Structure

Test consists of multiple choice A – D questions, multiple choice / multiple answer questions (checkboxes), and drag and drop answer sets.  Furthermore, the test also contains case studies.  Case studies consists of a fictional project concept that consists of business requirements, technical requirements, and code samples.  The questions will be related to the case study (scenario) and range from questions about debugging the code samples, questions about adding new functionality that meet the technical requirements and business needs, to conceptualizing / architecting scalable solutions.
So you probably read through that last atrocity of a run-on sentence and said to yourself, “ummm…  what?”  Do not be too overly worried about these questions.  You will see when you take the test that they’re not nearly as scary as they might sound.  Despite the fact that the test is timed, my recommendation is that you still take the time to read through the entire background information for the case study before proceeding to the questions section.  Some of the questions, you can get correct just by knowing what the technical requirements are for the case study.  Those are freebies, so take the time to read the sections and the time spent will be well worth it.
    

Test Content

As mentioned before in this post, many of the questions are very straight forward and hit on a specific features within the MVC 4 stack, but others are definitely more conceptual and require you to use critical thinking skills.  Therefore, it is very important that you not only understand the technical details of MVC 4 solutions prior to the test, but that you understand different applications (even infrastructure) architectures and what the benefits are of taking different approaches.  I don’t intend to scare you too much though.  Just spend the time studying, and you will be fine.
I would say that roughly 25-30% of the questions were more critical thinking questions than technology feature focused.  I actually remember (to the T) several of the questions, but I can’t repeat them here (sorry but maintaining my integrity as I promised Microsoft I would not divulge specific test questions).
  

Design the Application Architecture


  

Design the User Experience


  

Develop the User Experience


  

Troubleshoot and Debug Web Applications


   

Design and Implement Security


    

Final Thoughts


Hopefully this post will help you pass the 70-486 exam, Developing ASP.NET MVC 4 Web Applications.  If you found this information helpful, or have any thoughts or suggestions to add, please do so using the comments sections below.  Furthermore, share this with your friends and co-workers using the the social icons (Twitter, Facebook, etc).  I wish you the best of luck on your test.  Come stop by afterwards and let me know through the comments or on twitter (@myerscj) on how you do.



http://www.bloggedbychris.com/2012/11/06/microsoft-exam-70-486-study-guide/