Thursday, March 26, 2015

Fluent Nhibernate : Create Table from Code(Class- CodeFirst)

Now days,  Convention over configured is more preferred and that’s why Fluent Nhibernate got more popularity Because with Fluent Nhibernate we don’t have to write and maintain mapping in xml. You can write classes to map your domain objects to your database tables. If you want to learn how we can do this with existing database and Fluent Nhibernate, I have also written a blog post about CRUD operation with Fluent Nhibernate and ASP.NET MVC . After writing this blog post I was getting a lots of emails about how we can create database from the Fluent Nhibernate as we can do same with Entity Framework Code First. So I thought it’s a good idea to write a blog post about it instead of writing individual emails.

How to create tables from class via Fluent Nhibernate:

To Demonstrate how we can create tables based mapping classes create we’re going to create a console application via adding new project like below.

Sunday, March 22, 2015

Entity Framework Internals: Enum Support

In .NET world, We all are using Enums in our code. It’s makes our code more readable then using hardcoded numbers of strings. Entity Framework 5.0 or higher version has support for Enums. In this blog post we are going to see how we can use Enums with entity framework.

We are going to create a console application to see how it’s works. I’m going to create a console application for the same.


After creating a application I’ve added Entity framework via Nuget package.

Saturday, March 21, 2015

Entity Framework internals :IEnumerable and IQueryable

Now days, Entity framework is one the most used ORM in .NET world. Still I can see lots of people confused with IQueryable and IEnumerable. If they dont' know what is difference between them then they are going to make mistakes .When you first look at it both looks same. But there are quite differences and If you don’t understands internals of it then it will impact your query performance also.

IEnumerable vs IQueryable:

Here is the basic difference between IEnumerable and IQueryable. When you write queries with IEnumerable it executes queries on Server and load data in memory and then filter data on client side. This will be a problem when you are fetching large amount of data. While IQueryable executes queries on server side with all filters and then load all data into memory.


Sound complex!. Let’s write a simple example to understand it better. I am going to create a simple table in database called student table.

Friday, March 13, 2015

NSubstitute Introduction and Why I like it

Recently I am heavily learning Test Driven Development and Domain Driven design. As you know With TDD you need to have a mocking libraries. So after doing on research on internet they are three libraries available in Microsoft.NET development world which are quite mature.

  1. Rhino Mocks
  2. NSubstitute
  3. Moq
I have gone through all of above three and then After doing research and I choose NSubstitute.

Why I Choose NSubstitute:

Following are the reasons why I have chosen NSubstitute.

  1. It is super easy to use. I don’t have to write very complex lamda expressions to mock objects.
  2. It works really fine with all framework of Test Driven Development
  3. As it is super easy to use you need to write very less code to mock objects.
  4. With other Visual Studio plugins like Resharper, Telerik Justcode its works perfectly and they are able to generate code for the same.
  5. It’s got fluent syntax and very easy to understand.
  6. It’s perfect for some one who is not mature enough for Test Driven Development.

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog


My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews