Thursday, October 24, 2013

Lights, Camera, Action Delegates!

I recently worked on a project that a number of other developers collaborated on. All of the contributors to the project are very smart people, and I was impressed by much of the work that they had done. But one thing caught my eye, and I want to write a post about it since there are folks out there that are not familiar with this technique.

The Func and Action delegates were introduced in .Net 3.5 and they have a variety of uses. One of the best uses that I have found for them is to separate procedural code from actual business logic. Specifically, I like to create methods that accept an action delegate to control database, Entity Framework, or Linq to Sql contexts, and WCF service operations.

In the project I was working on I repeatedly found classes in the data layer with code like this (in this example a connection object has already been created and passed into the class) :

IDbCommand dbCommand = connection.CreateCommand();
dbCommand.CommandText = "Command_Text";

    if (dbCommand.Connection.State == ConnectionState.Closed)

catch (Exception ex)
    Log.DefaultLog.WriteVerbose(ex.Message + Environment.NewLine + ex.StackTrace);
    throw ex;
    if (dbCommand != null && dbCommand.Connection != null && dbCommand.Connection.State == ConnectionState.Open)

Friday, August 16, 2013

SSIS and SharePoint List Sources with Lookup Fields

If you are not familiar with the Microsoft SQL Server Community Samples: Integration Services site, then I recommend that you check it out:

The site contains excellent SSIS samples and documentation on how to build solutions for everyday problems using SSIS. One of the most useful samples covers using a SharePoint list as a data source. A special SSIS Data Adapter project has been created and packaged so that you can run an installer and then use SharePoint lists in your SSIS package. The project can be found here:image

After following the installation procedure you end up with a SharePoint List Source and SharePoint List Destination in your toolbox.
You can then use these sources and destinations in any Data Flow Task.

While using the SharePoint List sources today I ran into an issue using a lookup field. Essentially, my package was copying data from a SharePoint list into a local database table. The data exposed by the List Source included the internal SharePoint lookup value.image Essentially, it was including the field type and the separator (in this case ‘string;#’), which I did not want in my table.

There is an easy fix to remedy this situation though.

Thursday, August 8, 2013

SharePoint RenderingTemplate Gotcha!

Recently when working on a SharePoint 2010 project I let a minor mistake cause a great deal of frustration. I was creating a custom field that used a custom rendering template. I have done this before, but I guess on this day my mind was in WebForms land and I ended up with a solution that would deploy, but when I went to access my custom field, it would not render.

Here is a picture of my template… can you see the problem?


I had included the button OnClick call in the control markup. If you do this, your template will not render because it does not know how to wire up that event to it’s respective event handler. Take note of the Control declaration. Unlike normal ASP.Net User Controls, there is no reference to a Code Behind or Inherited Type… therefore… any events that need to be wired up will have to be done in your RenderingTemplateControl class file, and not in the markup!

I hope this helps!

Friday, August 2, 2013

The Changeling

Today’s society is moving faster than ever, and much like the rapidly evolving technology that we depend on, we ourselves are evolving faster and faster. Not physical evolution mind you, but mental evolution. Our minds are under enormous pressure to adapt, change, and evolve in order to keep pace with the ever-changing landscape that is modern life. Technology is driving this change, and those people who work with technology are most influenced by this “Hyper-evolution”.
The saying:
“it’s not what you know, but who you know”
…is still true in many ways, but the new world order requires a new saying:
“It’s not what you know, it’s what you can learn”

Saturday, June 15, 2013

Creating JavaScript List Repositories for the SharePoint REST API

I've recently been working on a project where I've been leveraging the SharePoint 2010 REST API. It is a great experience especially after moving from SharePoint 2007 client side development. I've been able to develop web parts that are 100% client driven with no reliance on any server side code other than the REST services that SharePoint already exposes.

As I began developing I quickly noticed that calls to jQuery ajax and getJSON functions were littering my code. Of course, these calls are completely necessary, but I wanted to find a way to reduce duplication, increase reuse, and create a better programming experience for the rest of the effort. I decided to take these calls and create a wrapper object that would be responsible for the plumbing of calling my lists. What I ended up with was an object very similar to a traditional repository used in other languages.

Thursday, March 7, 2013

Validating your data and your feelings with IE 10 and HTML 5

On a recent project I ran into an unexpected issue while testing with IE 10. The site that I was working on has out of the box ASP.Net validators and custom ASP.Net validators. When I navigated to the page that contains the validators and attempted to submit the form, multiple validators fired.