Everything you need to know about BCS – Intro

Business connectivity services is an integral part of Microsoft SharePoint Server when it comes to interacting with external systems (i.e. Line of Business Systems). There lots of tools and foundation from QCRUD operations to out-of-the-box web parts to let you surface the data and let users interact with it. For when you need to go further there is a capabale object model that can be utilized to make custom solutions most probably used to develop custom web parts. There is a visual designer in Visual Studio 2010+ that makes it easier to design and validate the interface between SharePoint and your external system. In SharePoint 2013, Microsoft has taken it to the next level by supporting OData, event listeners, apps, REST interface and a better external list (still could be better 😉 ).

With all these said, what makes working wih BCS complex is the shortage of learning resources and the way its object model and BDC files (interface definition) are design (specially the latter). You cannot even trust the documentations on MSDN sometimes (I will come back to this later). Although there are blog posts here and there to help you move forward, sometimes you are on your own to discover hidden gems and pitfalls.

In these series of posts my aim is to share my experience in building real world BCS solutions so you can save valuable development time by focusing on more productive tasks. I will try to show you the safe paths and pitfalls and be as complete as possible. There is not much difference between SharePoint 2010 and 2013, but when things are a little different I will show you how. At the end, comments are always welcome!

Comming up:

  • Part 1 – What can I build and what is the best way to do that?
  • Part 2 – Interacting with databases (SQL Server and Oracle as examples)
  • Part 3 – Interacting with other sources / .NET Connectivity Assemblies
  • Part 4 – Interacting with dynamic sources / Custom Connectors
  • Part 5 – Searchable BCS solutions
  • Part 6 – Enhancing BCS Performance
  • Part 7 – Surfacing BCS with search
  • Part 8 – Surfacing BCS with out-of-the-box web parts
  • Part 9 – Surfacing BCS with custom web parts
  • Part 10 – Surfacing BCS with Java Script and JSON (MVVM) in SharePoint 2010
  • Part 11 – Adding CSOM support to BCS in SharePoint 2010
  • Part 12 – Business Data Catalog file, the complete reference
  • Part 13 – Bullet-proof deployment of BCS solutions in Farm
  • Part 14 – BCS and Claims-Based-Authentication considerations

Do you have any suggestions for another part? then let me know in the comments.

First step in developing apps for SharePoint Online – Enabling F5

It’s Just a quick post to share one of my first experiences with SharePoint online and that’s how to enable F5 experience in Visual Studio. When you start writing your first App for SharePoint Online you might get the same error as me, saying that “Sideloading of apps is not enabled on this site”

Sideloading of apps is not enabled on this site
Sideloading of apps is not enabled on this site

It’s because the “Developer” feature is not activated by default and you need to activate it manually, but since it’s an online version of SharePoint things are a little bit different that you local development environment (a good article on how to prepare your local development environment) and you need to use CSOM (Client Side Object Model). I have just translated the c# equivalent to a few lines of PowerShell code so you can type it into your SharePoint Online Management Shell (if you have not installed it, you can download it from here). Here is the code:

<br />$siteurl = "https://yourwebsite.sharepoint.com"<br />$username = "yourusername"<br />$password = ConvertTo-SecureString -String 'yourpassword!' -AsPlainText -Force<br />[Microsoft.SharePoint.Client.ClientContext] $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)<br />[Microsoft.SharePoint.Client.SharePointOnlineCredentials] $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)<br />$context.Credentials = $credentials<br />$site = $cc.Site<br />$sideLoadingGuid = New-Object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"<br />$site.Features.Add($sideLoadingGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)<br />$context.ExecuteQuery();<br />

A simple trick to gain some optimization in your code

I see some times developers do not optimize recursive functions to put less load on stack although many times it can be done with some simple changes in the code without even affecting usability. Lets assume we have a recursive function like the following (which is a C# implementation of the Wikipedia version mentioned here):

public void QuickSort(int[] array, int left, int right) {
  If (left < right) {
    int pivot = Partition(array, left, right);
    QuickSort(array, left, pivot - 1);
    QuickSort(array, pivot + 1, right);
  }
}

To reduce the call stack depth change the if to while and instead of second recursive call to QuickSort change the left index like this:

public void QuickSort(int[] array, int left, int right) {
  while(left < right) {
      int pivot = Partition(array, left, right);
      QuickSort(array, left, pivot - 1);
      left = pivot + 1;
  }
}

Some compilers (e.g. F#) detect and optimize these kind of calls in recursive function (tail recursion), but C# is not one of them. IMHO these kind of optimizations are the responsibility of the developer and compiler needs to focus on many different type of optimizations.
Before I forget and just to be complete, here is the the implementation of Partition function:

private int Partition(int[] array, int left, int right, int pivot){
  int pivotValue = array[pivot];

  // Move pivot to the end of the array
  Swap(array, pivot, right);

  int sortIndex = left;

  for (int i = left; i < right; i++) {
    if (array[i] < pivotValue) {
      Swap(array, i, sortIndex);
      sortIndex++;
    }
  }

  // Move pivot its new place
  Swap(array, sortIndex, right);

  return sortIndex;
}

My study guide for Exam 70-487 Developing Windows Azure and Web Services

Developing Windows Azure and Web Services (70-487) is the last exam you need to pass in order to receive the MCSD Web Application, Microsoft’s latest certification for web development. Unfortunately there is no single book that covers the topics in this exam and one of my worries when studying for this exam was how the questions are aligned with the recent changes in the Azure platform. Here I can give you a hint 😉 if you have learned / have experience with Azure in the past or recently you won’t have any problem figuring out the best answer for a question.

If you have already passed the two other exams (70-480, 70-486) this one is going to be a bit more tricky and my recommendation is to carefully review the “Skills measured” section of the official exam page from here.

before continuing I first recommend reading Chris’s blog post “Microsoft Exam 70-487 Study Guide“. He has put together a valuable list of content that you use. If you don’t have enough experience I highly recommend PluralSight videos that are recommended by him.

Another blog post by Tobias, “Microsoft exam 70-487 study guide” in my opinion contains better references, so make sure you don’t miss this one too.

Another blog post by Chris “Microsoft Exam 70-487 Study Notes

I only want to add my recommendations if you have studied the exam topics and almost ready for the exam.

Accessing Data (24%)

  • Know all the technologies that are available in Azure for data storage (i.e. Table storage, SQL Azure, CDN, Caching) and which one is more recommended for which scenarios
  • Get yourself familiar with System.Transactions namespace (http://msdn.microsoft.com/en-us/library/system.transactions.aspx) How transaction works in .NET and how you can use it

Querying and Manipulating Data by Using the Entity Framework (20%)

Designing and Implementing WCF Services (19%)

Creating and Consuming Web API-based services (18%)

Deploying Web Applications and Services (19%)

  • I have nothing to add here. Just refer to the other blogs I recommended above.