Monday, September 29, 2014

Wednesday, September 24, 2014

How to solve problem while upgrade to EF6: System.InvalidOperationException: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

To solve this problem for me is to add EntityFramework.SqlServer.dll into project reference:

System.InvalidOperationException: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

Tuesday, September 23, 2014

How to add Facebook comment in ASP.NET MVC project?


You can download solution on Github by

https://github.com/raysaspnet/facebookcomment

1. Create a partial view, call fbComment

2. Add this partial view into any view for comments
@RenderBody()
@Html.Partial("fbComment")


https://developers.facebook.com/docs/plugins/comments

Monday, September 22, 2014

The case-insensitive regular expression for Canada postal code

^[abceghjklmnprstvxyABCEGHJKLMNPRSTVXY]\d[a-zA-Z]\d[a-zA-Z]\d$

Friday, September 19, 2014

How to display Textbox input to upper case in ASP.NET MVC razor view?

1. Create css class
.uppercase
{
text-transform: uppercase;
}

2. Add this class into Textbox in razor view
@Html.TextBoxFor(model => model.PostCode, new { @class = "uppercase" })

Note: the value still keeps original value.

Thursday, September 18, 2014

How to write Singleton pattern in C#?

http://msdn.microsoft.com/en-us/library/ff650316.aspx
using System;

public sealed class Singleton
{
   private static volatile Singleton instance;
   private static object syncRoot = new Object();

   private Singleton() {}

   public static Singleton Instance
   {
      get 
      {
         if (instance == null) 
         {
            lock (syncRoot) 
            {
               if (instance == null) 
                  instance = new Singleton();
            }
         }

         return instance;
      }
   }
}

No more JS frameworks

http://bitworking.org/news/2014/05/zero_framework_manifesto

Tuesday, September 2, 2014

What Is Clean Code?

http://java.dzone.com/articles/what-clean-code-%E2%80%93-quotes
I like this one by Dave Thomas, founder of OTI and godfather of the Eclipse strategy:
It has unit and acceptance tests.
It has meaningful names.
It provides one way rather than many ways for doing one thing.
It has minimal dependencies, which are explicitly defined, and provides a clear and minimal API.
Code should be literate since, depending on the language, not all necessary information can be expressed clearly in code
alone

If programming languages were weapons

http://bjorn.tipling.com/if-programming-languages-were-weapons

C# is a powerful laser rifle strapped to a donkey, when taken off the donkey the laser doesn’t seem to work as well.