"Done is better than perfect."


SimpleMembership with an existing database.

I’ve been trying the SimpleMembership today and I just love it, the Asp.Net team came out with the simplest solution, great! Managing users and their rights has always been a pain using the built in Membership feature pushing many developer to write their custom user/role tables, spending a lot of time in configuration and extending […]




SQL Collation conflict

While attempting to copy  records from older database backup I’ve encoutered the following : Msg 468, Level 16, State 9, Line 5 Cannot resolve the collation conflict between “Latin1_General_CI_AS” and “SQL_Latin1_General_CP1_CI_AS” in the equal to operation. Possibly caused because the file comes from SQL Server 2008 while now I’m on the 2012.  Luckly easy to […]




SQL Query by year or month




Resize your images for Facebook

This an old utility I wrote a couple years ago in order to resize the images downloaded from my digital camera. After a recent trip to Spain where me and my friends took a lot of pictures, I tough it worthed to pick up again the solution and give it a refresh. Instead of uploading […]




Fluent interfaces introduction and sample.

Learning how to write a fluent interface can help when you want to write the next ORM or if you just wonder how to concatenate your methods in a LINQ style. I’m particularly interested in using this technique to write Html helpers. Anyway, let see a basic example. A simple calculator class/interface , using a […]




Easy join tables with EF Code First.

Entity Framework Code First is getting even better, release after release. Here’s how to easily get a many to many relationship between two entities. Not to much to do really, once the relationship is specified within the two classes (an ICollection navigation property for each of the two ends in the relation), EF will take […]




Default value if null object in an extension method.

Sometimes you need to get a value from a nested object and in order to do it we need to be sure that the object hierarchy do not have any null objects in it. This lead to a long series of checks. Here an example, assuming we got these entities: Code Snippet   public class Country […]




Developer homework test.

Below you can find a test I received via email long time ago. Also, in this attachment there’s what I think is a good solution, any tough or suggestion is appreciated ! Developer Homework Please write code to fulfill the requirements of the following user stories. We are looking for answers that demonstrate good test […]




Ignore all non exisisting properties with Automapper

Code Snippet public static class MappingCustomExtension {     public static IMappingExpression<TSource, TDestination> IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)     {         var sourceType = typeof(TSource);         var destinationType = typeof(TDestination);         var existingMaps = Mapper.GetAllTypeMaps().First(x => x.SourceType.Equals(sourceType) && x.DestinationType.Equals(destinationType));         foreach (var property in existingMaps.GetUnmappedPropertyNames())         {             expression.ForMember(property, opt => opt.Ignore());         }         return expression;     } }




MVC3 Retrieving the browser Url

Code Snippet Public Module MyUrlExtensions     <Extension()> _     Public Function UrlOriginal(ByVal request As HttpRequestBase) As Uri         Dim hostHeader As String = request.Headers(“host”)         Return New Uri(String.Format(“{0}://{1}{2}“, request.Url.Scheme, hostHeader, request.RawUrl))     End Function End Module