How to use PagedList In MVC

PagedList.Mvc is one of many good paging and sorting packages for ASP.NET MVC, in the below simple example I'm gonna to implement it for content (posts) of a blog post, install the PagedList.Mvc via nuget and take a look at this code. This is an action which returns blog posts:

  1.        public ActionResult List(int? page)
  2.         {
  3.             var posts = _blogService.GetAllBlogPosts();
  4.             var pageNumber ... Continue

Redis as a cache server

Although Redis is much more than a cache, But it's possible to use as cache server specially in distributed applications. Redis lets you operate on the values and it's just a key value pair in memory database.

To getting start, get the latest version of Redis from here and install in your  windows machine (Server) by instruction and run it in your services. Redis runs in your server machine (you can have redis server and client in one machine which could be you client development machine) and you call it from client by a library... Continue

Multiple submit buttons in MVC

In MVC you can submit a form by @using(Html.BeginForm()). You can Post the model you have binded via this operation and command the begin form to post to a Post action:   @using(Html.BeginForm("Create","FooController")).

Now if you have more than one submit button to send the page content to different post action, there are few ways: one of them is to post the content to a specific action and then decide in it to redirect which action:


  1. <input type="submit" value="Field1" name=&quo... Continue

Domain driven design VS model driven architecture

Domain Driven design(DDDesign) is not the same Model Driven Architecture(MDA). Although The root of both DDDesign and MDA is the same and it is Model Driven Engineering and also both of them aim to solve the problem of converting a 'pure' problem domain model into a full software system. But there are some differences.

Domain Driven Design concentrates on Modeling and solving the Domain problem by Capturing the model from Ubiquitous language. it is about m... Continue

What's the DDD-lite?

Based on Vaughn Vernon 's definition , "DDD-Lite is a means of picking and choosing a subset of the DDD tactical patterns, but without giving full attention to discovering, capturing, and enhancing the Ubiquitous Language." most of DDD-like approaches are not really DDD! If you don’t have bounded contexts so Ubiquitous language(UL) doesn't mean anything and if you have no UL, you won't have business rules.

In DDD, you should ... Continue

Disadvantages of n-layered architectures

Most of the people use n-layered architectures in their application developement. There are lots of advantage for n-layered architecture but I want to talk about disadvantages. actually it's not a good idea to design a somplex architecture for every problem , you don't need to apply n-layered architecure in every case because it's mostly about making complex things simple whilst a complex architecture can make a system more and more hard to understand rather than making performance problems. Based on this pr... Continue

Introducing sqlbulktools

In my previews blog post I wrote about Z.bulkOperation. I migrated to sqlbulktools just because it's free with the same ability!(to be frank). Now to see the reason of my migration, fire up visual studio and Install the latest version of the library using the following command in console package manager:

Install-Package sqlbulktools

And get started!

  1.  static void Main(string[] args)
  2.         {
  4.           &nb... Continue

Fluent Nhibernate Sample Project in MVC

Nhibernate is an ORM designed for Microsoft.Net, it's free and open source and it's a port of java mapper to Dot Net. And fluent Nhibernate is a separate version of Nhibernate which lets you write your entities according to your business instead of starting from creating tables, fluent Nhibernate is just a fluent API for mapping classes with NHibernate. what an ORM does, is persisting object In database and then retrieving when it is needed, indeed it translates the object to database and vice versa.

In Entity Framework yo... Continue

Difference between layer super type and template method patterns

About two days ago I asked a question about the differences of these two patterns. after reading about the template method patterns in detail I found that although there are lots of similarities between them but layer super type is not the same as method template and vice versa. I've blogged about Layer Super type before in here, now I want to talk about method template pattern. Basical... Continue

Layer Supertype pattern with example in C#

First of all look at the definition by @martinfowler "A type that acts as the supertype for all types in its layer" all you need is a Supertype Class for all the Objects. I usually use it in Repository layer as a generic Repository. I recommend to use it if you have more than one kind of object in your layer. Let's consider an example in real world , Create a class and name it Profile

  1.    public class Profile
  2.     {
  3.         public string Name { get; set; }
  4.     &n... Continue