Flattening object with AutoMapper

I blogged about basic concept of AutoMapper before. AutoMapper supports flattening complex object model into DTO or other simple object model. For example, domain model usually has complex object model with many associations between them, but view model has flat object model. We can map domain object model to view object model with AutoMapper’s flattening. If you follow the naming convention of your destination object model, then you don’t need to provide any configuration code to AutoMapper. AutoMapper work with convention based and map your object model from complex to flat/simple one.

Continue reading “Flattening object with AutoMapper”


In programing we often need to map one object to another. For example, suppose you are working with MVC pattern and you need to map your domain model with view model. This kind of mapping code are time consuming to write and not easy to test. So why not use a tool which take the heavy lifting for us.

Continue reading “AutoMapper”

Populate drop down list from enum in ASP.NET web form

Drop down list is used to show various items on the user interface to select one from them. It is very useful specially when we have not much space in the user interface. When user click on the list then it drop with all the information, from which one can be selected. It is so common to populate a drop down list from database data. But in other case we need to populate it from other source also, like an enum. So how do we populate a drop down list from an enum?

Continue reading “Populate drop down list from enum in ASP.NET web form”

Demo on TDD – new GitHub repository

Today I have published a new repository at GitHub. A demo application on how we should design our application so that we can test it. It is a test driven development approach. Before implementing the actual code write the test case and let that be failed. Then implement the logic to pass the test case. Our development is guided by test cases. This is called test driven approach. Also some programmer call this red-green approach. Red stands for fail at first and green for pass latter on. This approach help our code to be on track and easy to main in future. Because all the layers have to decouple for that. Our actual requirement (test cases) guide our development.

Continue reading “Demo on TDD – new GitHub repository”

Scaffolding in ASP.NET MVC 4.0

Scaffolding is one of the nice feature in ASP.NET MVC. The main purpose of scaffolding is it creates a starting point of code for you. Whatever application you are developing, you need to create Controller, Action Methods, Views and probably a database connection. Without scaffolding you need to do almost similar kind of job every time. It actually save some of your time by creating the basic code structure for you, on which you can start your work. You can change the scaffolding code to meet your exact requirement. Keep in mind that scaffolding code is not the final application code. It is just a starting point from you need to continue. If you are not happy with the way scaffolding works. You can change it. You can configure it to create basic starting code structure of your choice.

Continue reading “Scaffolding in ASP.NET MVC 4.0”