Friday 4 September 2015

Working with SharePoint Lists though Client Object Model

How to get SharePoint List Items through SharePoint Client Object Model


  • Iterate List Items
ClientContext clientContext = new ClientContext("Site URL");  
 NetworkCredential Cred = new NetworkCredential("UserName", "Password", "Domain");  
 clientContext.Credentials = Cred;  
 Web web = clientContext.Web;  
  Microsoft.SharePoint.Client.List lst = clientContext.Web.Lists.GetByTitle("List Name");  
   ListCollection fieldList = web.Lists;  
       clientContext.Load(fieldList);  
       // Execute the query to the server.  
       clientContext.ExecuteQuery();  
       foreach (Microsoft.SharePoint.Client.List lstobj in fieldList)  
       {  
         Console.WriteLine("\n"+"Title:" + lstobj.Title);  
         Console.WriteLine("Description:" + lstobj.Description);  
         Console.WriteLine("Created:" + lstobj.Created);  
         Console.WriteLine("\n");  
       }  
       Console.ReadLine();  
  • SharePoint List Item count
ClientContext clientContext = new ClientContext("Site URL");  
 NetworkCredential Cred = new NetworkCredential("UserName", "Password", "Domain");  
 clientContext.Credentials = Cred;  
 Web web = clientContext.Web;  
  Microsoft.SharePoint.Client.List lst = clientContext.Web.Lists.GetByTitle("List Name");  
       clientContext.Load(lst);  
       clientContext.ExecuteQuery();  
       int cnt = lst.ItemCount; 
       Console.WriteLine(cnt);  
       Console.ReadLine();  

Sunday 12 April 2015

How to get SharePoint List Content Type Through CSOM - Client Object Model

How to get Content Type of particular list.

Code:

ClientContext clientContext = new ClientContext("Site URL");  
 String strPassword = "Password";  
 var passWord = new SecureString();  
 foreach (var c in strPassword.ToCharArray()) passWord.AppendChar(c);  
 NetworkCredential Cred = new NetworkCredential("Username", passWord, "Domain");  
 clientContext.Credentials = Cred;  
  ContentTypeCollection contentTypeColl = clientContext.Web.Lists.GetByTitle("ContetType Name").ContentTypes;  
       clientContext.Load(contentTypeColl);  
       clientContext.ExecuteQuery();  
       //// Display the Content Type name  
       foreach (ContentType ct in contentTypeColl)  
       {  
         Console.WriteLine(ct.Name);  
       }  
       Console.ReadLine();  

Thursday 9 April 2015

How to access Web Site through SharePoint Client Object Model

You can access WebSite  Properties through SharePoint Client Object Model.
Microsoft.SharePoint.Client should be use.


Code: 
ClientContext clientContext = new ClientContext("Site URL");

NetworkCredential Cred = new NetworkCredential("UserName""Password", "Domain");
clientContext.Credentials = Cred;
Web web = clientContext.Web;

clientContext.Load(web);
clientContext.ExecuteQuery();

Console.WriteLine("Title:" + web.Title);
Console.WriteLine("Description:" + web.Description);
Console.WriteLine("Created:" + web.Created);
onsole.ReadLine();



If you want to access only specific properties from WebSite, it can be achieved using LINQ.

Code:

ClientContext clientContext = new ClientContext("Site URL");

NetworkCredential Cred = new NetworkCredential("UserName""Password""Domain");
clientContext.Credentials = Cred;
Web web = clientContext.Web;

clientContext.Load(web, a => web.Title,
                        a => web.Description,
                        a => web.Created);clientContext.ExecuteQuery();

Console.WriteLine("Title:" + web.Title);
Console.WriteLine("Description:" + web.Description);
Console.WriteLine("Created:" + web.Created);

onsole.ReadLine();

Sunday 9 December 2012

Visual Studio 2010 Keybinding


Get Visual Studio 2010 Key bindings  from Here


Visual Studio 2010 / Visual Studio 2012 Extensions


Visual Studio 2012

Productivity Power Tools
                                                                                                                                                                                          
Snippet Designer

Spell Checker

Web Essentials 2012




Visual Studio 2010

PowerCommands for Visual Studio 2010

Productivity Power Tools

Visual Studio Color Theme Editor

Web Essentials

Friday 30 November 2012

Link Server

Link Server




Linked Servers is a concept in SQL Server by which we can add other
SQL Server to a Group and query both the SQL Server dbs usig T-SQL Statements.
With a linked server, you can create very clean, easy to follow, SQL statements that allow remote data to be retrieved, 
joined and combined with local data.
Stored Procedure sp_addlinkedserver, sp_addlinkedsrvlogin will be used add new Linked Server. 

Increase SQL Server stored procedure performance



 Increase SQL Server stored procedure performance



1. SET NOCOUNT ON
This help to stored procedures to stop the message indicating the number of rows affected by a Transact-SQL statement.

This can reduce network traffic.

2.Use return values


3.Don't write select * from [tablename]

write select [columnname1],[columnname2] from [tablename]
This helps to speed of the query.


4.Don't use Prefix "Sp_" in your store procedure.

Becoz if you use "Sp" then SQL Server looks in the master database then your database.


5.Use sp_executesql stored procedure instead of the EXECUTE statement.


6.Avoid using temporary tables inside your stored procedure.

Becoz Using temporary tables inside stored procedure reduces the chance to reuse the execution plan.


7.Avoid using DDL (Data Definition Language) statements inside your stored procedure.

Using DDL statements inside stored procedure reduces the chance to reuse the execution plan. 




Translate