Notes, tips and tricks

  • Ninject and ASP.NET Web API

    WebAPI was appeared in beta version of ASP.NET MVC4 with a new namespace. System.Web.Http is an analogue of System.Web.Mvc namespace with ApiController class, action filters, and many other similar classes with which we are familiar from the ASP.NET MVC. There is IDependencyResolver that is an analogue of IDependencyResolver from System.Web.Mvc. And I find it necessary to write my own realization of IDependencyResolver for Ninject.

  • RazorEngine

    You can use .cshtml templates to create text content, for example for massive email sending slightly different for each user. There are at least two ways to do it.

  • EF Code First Attached/Detached entities

    POCO-classes in Entity Framework Code First might have two states: attached and detached. In the state attached to the context all changes are detected and in case they exist, the use of method SaveChanges() writes current state to database. If the object is not attached, the changes won't certainly be detected and saved to the database.