sharepoint 2010 code sample Links

http://www.sharepoint-tips.com/2006/08/common-and-simple-coding-tasks-in.html

using(SPSite mySite = new SPSite("http://server/sites/site"))
{
   using(SPWeb myWeb = mySite.OpenWeb())
   {
      string linksHtml = "";
      foreach(SPList list in myWeb.Lists)
      {          
         string listLink = "<a href='" + list.DefaultView.Url.ToString()          + "'>" + list.Title + "</a>(<b>"+list.Items.Count+"</b>)<br>";
         linksHtml += listLink;
      }
   }
}

--
using(SPSite mySite = new SPSite("http://server/sites/site"))
{
   using(SPWeb myWeb = mySite.OpenWeb())
   {
   }
}
--
using(SPSite mySite = new SPSite("http://server/sites/site"))
{
   using(SPWeb myWeb = mySite.OpenWeb())
   {
      string linksHtml = "";
      foreach(SPList list in myWeb.Lists)
      {          
         string listLink = "<a href='" + list.DefaultView.Url.ToString()          + "'>" + list.Title + "</a>(<b>"+list.Items.Count+"</b>)<br>";
         linksHtml += listLink;
      }
   }
}
------


---------------
http://sharepoint-coding.blogspot.com/

Sharepoint Large List pagination Implementation



SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["Announcements"];

SPQuery oQuery = new SPQuery();
oQuery.RowLimit = 10;
int intIndex = 1;

do
{
    Response.Write("<BR>Page: " + intIndex + "<BR>");
    SPListItemCollection collListItems = oList.GetItems(oQuery);

    foreach (SPListItem oListItem in collListItems)
    {
        Response.Write(SPEncode.HtmlEncode(oListItem["Title"].ToString()) +"<BR>");
    }

    oQuery.ListItemCollectionPosition = collListItems.ListItemCollectionPosition;
    intIndex++;
} while (oQuery.ListItemCollectionPosition != null);

------------------------------------------------------------------------
 
Retrieving Items with SPList.GetItems
 
SPQuery query = new SPQuery();
SPListItemCollection spListItems ;
string lastItemIdOnPage = null; // Page position.
int itemCount = 2000

while (itemCount == 2000)
{
    // Include only the fields you will use.
    query.ViewFields = "<FieldRef Name=\"ID\"/><FieldRef Name=\"ContentTypeId\"/>";  
    query.RowLimit = 2000; // Only select the top 2000.
    // Include items in subfolder (if necessary).
    query.ViewAttributes = "Scope=\"Recursive\"";
    StringBuilder sb = new StringBuilder();
    // To make it order by ID and stop scanning the table, specify the OrderBy override attribute.
    sb.Append("<OrderBy Override=\"TRUE\"><FieldRef Name=\"ID\"/></OrderBy>");
    //.. Append more text as necessary ..
    query.Query = sb.ToString();
    // Get 2,000 more items.

    SPListItemCollectionPosition pos = new SPListItemCollectionPosition(lastItemIdOnPage);
    query.ListItemCollectionPosition = pos; //page info
    spListItems = spList.GetItems(query);
    lastItemIdOnPage = spListItems.ListItemCollectionPosition.PagingInfo;
    // Code to enumerate the spListItems.
    // If itemCount <2000, we finish the enumeration.
    itemCount = spListItems.Count;

}
---------------------------------------------------------
 
Cache items
 
private static object _lock =  new object();

public void CacheData()
{
   SPListItemCollection oListItems;
       oListItems = (SPListItemCollection)Cache["ListItemCacheName"];
      if(oListItems == null)
      {
         lock (_lock)
         {
              //Ensure that the data was not loaded by a concurrent thread while waiting for lock.
              oListItems = (SPListItemCollection)Cache[“ListItemCacheName”];
              if (oListItems == null)
              {
                   oListItems = DoQueryToReturnItems();
                   Cache.Add("ListItemCacheName", oListItems, ..);
              }
         }
     }
}
---------------------
private static object _lock =  new object();

public void CacheData()
{
   DataTable oDataTable;
   SPListItemCollection oListItems;
   lock(_lock)
   {
           oDataTable = (DataTable)Cache["ListItemCacheName"];
           if(oDataTable == null)
           {
              oListItems = DoQueryToReturnItems();
              oDataTable = oListItems.GetDataTable();
              Cache.Add("ListItemCacheName", oDataTable, ..);
           }
   }
}

SPFX - HTTPClient - Curd Operations - SharePoint list.

  Create solution in the name of SpfxCrud. ISpfxCrudProps.ts export interface ISpfxCrudProps {   description : string ;     context : an...