Friday, July 25, 2014

Create an External List Using C#

In my previous 2 articles (Create SharePoint 2013 External List using Visual Studio 2012Extending External List Capabilities to Add and Edit List Items) I described how to create an External Content Type and create a list using that content type. 

In this article the focus will be on creating the list using C# rather using the SharePoint UI. Given the BDC Model goes in a farm level feature and create the external content type, the best option would have been writing the list creation code in the FeatureActivated method of the feature receiver. There are some issues I faced when creating this list. Given the BDC model deployment also associated with a feature receiver that is not visible, this was not possible to create a feature receiver for the feature that included the BDC model. There were some possible scenarios explained in some articles, but I did not follow them since there is another cleaner approach.

Therefore I created another feature and added a feature receiver for the second feature. The feature activation procedure needs to be done in an order. The second feature needed to be activated after the deployment of the first feature as the External Content Type needed to be presented before creating the list.

Friday, July 11, 2014

Extending External List Capabilities to Add and Edit List Items

In my previous article I mentioned how to create an external list using SharePoint 2013 to read list and read a particular list item. in this article I am planning to show how to allow adding new list items and editing list items which were disabled earlier.

I will be referring to the Visual Studio solution I created in previous article which can be found here. The step by step guide is as follows.

1. Double click on VSDemoModel to open the VSDemoModel.bdcm in the designer. The Entity1 object will be available. Select it. In the 'BDC Method Details' window you will find the 'ReadList' and 'ReadItem' methods. Scroll down the window till you find a cubic icon followed by a text '<Add a Method>'. 

Upon clicking on it, a drop down list will appear. Select 'Create creator method' option. A new method will be available as 'Create'. 

Thursday, July 10, 2014

Create SharePoint 2013 External List using Visual Studio 2012

Business Connectivity Services (BCS) are meant to provide access to data that relies out of the SharePoint environment. It can be a Web Service, SQL database, or even a .NET collection. The good thing about BCS is that it gives the real SharePoint feeling when external data is linked up with it. The data can be indexed to Search, Event Receivers(remote), Look and Feel, CRUD operations and etc... 

The important key element that comes with the BCS is 'External Content Type'. It handles the connectivity between SharePoint and external data source. 

The main focus of this article will be on how to deploy a BCS solution using Visual Studio 2013 for SharePoint 2013. 

1. Create a 'SharePoint 2013 - Empty' project in Visual Studio and name it as 'BCSVSDemo'. 

Click the 'OK' button and you will be navigated to the 'SharePoint Customization Wizard'. Mention the site URL and select the option 'Deploy as a farm solution'. Click 'Finish' button in order to complete project creation.

BCS in SharePoint 2013 @ SharePoint Sri Lanka User Group, July 2014 Meetup

  • What is a Business Connectivity Service?
  • Why use business connectivity services?
  • How to deploy a Business Connectivity Service? 

These were the key questions focused for the first session for the SharePoint Sri Lanka User Group meeting for July 2014. 
Connecting data from external data sources to SharePoint is something developers may see challenging. SharePoint 2013 has a really good feature (which was in SharePoint 2010 as well) further improved with multiple data source supports as well as features such as remote event receivers.

External Content Types provide the facility to connect the data to SharePoint and a Secure Store Service application can be used for providing the better authorizations. 

Slides of the presentation can be downloaded from below.

Monday, May 5, 2014

List View Threshold in SharePoint

It's been around 2 years I have started working with SharePoint and lists, libraries, user groups and etc.. are now seems like much interesting from the internal way they are handled. Never faced a situation where 5000+ list items are involved in the days of training and now it seems like the best times where I get to know the performance management is important and other considerations are much valuable when it comes to the development.

SharePoint has this interesting feature that actually saves the database servers being loaded with heavy queries on list items and it is called list view threshold. By default it is set to 5000 for normal users and 20000 for users with administrative privileges. This can be set to any value at anytime and also disable and allow any load to be put on the db server, which is equivalent to breaking the fence around the house and asking people to come in thousands.

Sunday, September 15, 2013

NDepend for Developers to Write Quality Code

Writing code is easy. But writing quality code is not that easy. Naming conventions, variables and constants defining, right use of the enums, class member visibility and many more things exists for the developer to be concerned with. In fact, you can save your customer as well as destroy him depending on the code you write sometimes. There are unit tests and load tests that Visual Studio provides inbuilt which you can asses the accuracy and speed of the code you write. Of course there are some best practices which should be followed but when you are a day before the code freeze, it is sometimes not likely to happen. 

I have tried out StyleCop which is a style analysis tool that works at the code level and FxCop which is a static analysis tool that works on the level of managed assembly. They give a lot of support for the developer to write some quality code. But what I am going to describe in the rest of article is a tool that do many times of work than any of these does. 

I got a message on LinkedIn from Patrick Smacchia, who is the CEO and Lead Developer of NDepend with an amazing gift. It's a free professional license for NDepend. I tried the tool for a few weeks and found some interesting features in it that could save my time and improve my code quality. So I used it to evaluate one of the projects I did about an year back. In a way I was really happy that I have recorded only 51 rules violations in a project with 232 classes when I was just 1 year experienced. 

Saturday, August 10, 2013

Introduction to Windows Phone 8 Development @ Sri Lanka .NET Forum, August 2013 Meetup

I got the opportunity to do my second Sri Lanka .NET Forum presentation on 8th August 2013. Even there were many presentations done by me on Windows Phone development at MS Champs Community and once for University of Kelaniya staff, this one looked bit different as the attendees are professional developers. So no free MSDN subscriptions or developer license for this crowd. 

As Windows Phone is an interesting topic for anybody who would love a smartphone, no need explain the interest of the crowd on the technology. The presentation took place after a fabulous presentation by MS Office MVP Dr. Nitin Sadashiv Paranjape which was scheduled at last minute.