Skip to main content


Showing posts from June, 2011

Code refactoring with Visual Studio 2010 Part-4

I have been writing few post with code refactoring features in Visual Studio 2010. This post also will be part of series and this post will be last of the series. In this post I am going explain two features 1) Encapsulate Field and 2) Extract Interface. Let’s explore both features in details.

Encapsulate Field:
This is a nice code refactoring feature provides by Visual Studio 2010. With help of this feature we can create properties from the existing private field of the class. Let’s take a simple example of Customer Class. In that I there are two private field called firstName and lastName. Below is the code for the class.

public class Customer { private string firstName; private string lastName; public string Address { get; set; } public string City { get; set; } }
Now lets encapsulate first field firstName with Encapsulate feature. So first select that field and goto refactor menu in Visual Studio 2010 and click on Encapsulate Field. Once you click that a dialog box will appear …

Code refactoring with Visual Studio 2010-Part 3

I have been writing few post about Code refactoring features of visual studio 2010 and This blog post is also one of them. In this post I am going to show you reorder parameters features in visual studio 2010. As a developer you might need to reorder parameter of a method or procedure in code for better readability of the the code and if you do this task manually then it is tedious job to do. But Visual Studio Reorder Parameter code refactoring feature can do this stuff within a minute. So let’s see how its works. For this I have created a simple console application which I have used earlier posts . Following is a code for that.

using System; namespace CodeRefractoring { class Program { static void Main(string[] args) { string firstName = "Jalpesh"; string lastName = "Vadgama"; PrintMyName(firstName, lastName); } private static void PrintMyName(string firstName, string lastName) { Console.W…

Code refactoring with Visual Studio 2010 Part-2

In previous post I have written about Extract Method Code refactoring option. In this post I am going to some other code refactoring features of Visual Studio 2010. Renaming variables and methods is one of the most difficult task for a developer. Normally we do like this. First we will rename method or variable and then we will find all the references then do remaining over that stuff. This will be become difficult if your variable or method are referenced at so many files and so many place. But once you use refactor menu rename it will be bit Easy. I am going to use same code which I have created in my previous post. I am just once again putting that code here for your reference.

using System; namespace CodeRefractoring { class Program { static void Main(string[] args) { string firstName = "Jalpesh"; string lastName = "Vadgama"; Print(firstName, lastName); } private static void Print(string firstName, s…

My blog post appearing on

Recently I was searching something and I found that one of the post about New Features of the SQL Server Denali was being discussed on Channel9 on MSDN. It’s a great pleasure and honour to have this kind of appreciation. I would like to thanks again Microsoft for giving opportunity and serve community. I would also like to thanks my readers who are giving me all the support and love.

Once again I am appealing good developers to start blogging. I have seen many great developers are who are doing great stuff but not blogging. I would like to say please please do the blogging and share your stuff with community and you will also get this kind of great appreciation.

Here is the link where they discussed that video.

Following is video where Dan and Clint from Microsoft discussed my blog post on channel 9.

Here are the stuff they have discussed during the video.
[00:30] Microsoft PressPass -…

Code refactoring with Visual Studio 2010 Part-1

Visual studio 2010 is a Great IDE(Integrated Development Environment) and we all are using it in day by day for our coding purpose. There are many great features provided by Visual Studio 2010 and Today I am going to show one of great feature called for code refactoring. This feature is one of the most unappreciated features of Visual Studio 2010 as lots of people still not using that and doing stuff manfully. So to explain feature let’s create a simple console application which will print first name and last name like following.

And following is code for that.

using System; namespace CodeRefractoring { class Program { static void Main(string[] args) { string firstName = "Jalpesh"; string lastName = "Vadgama"; Console.WriteLine(string.Format("FirstName:{0}",firstName)); Console.WriteLine(string.Format("LastName:{0}", lastName)); Console.ReadLine(); } } }
So as you can see this is a very basic console applica…

PetaPoco with parameterised stored procedure and Asp.Net MVC

I have been playing with Micro ORMs as this is very interesting things that are happening in developer communities and I already liked the concept of it. It’s tiny easy to use and can do performance tweaks. PetaPoco is also one of them I have written few blog post about this. In this blog post I have explained How we can use the PetaPoco with stored procedure which are having parameters. I am going to use same Customer table which I have used in my previous posts. For those who have not read my previous post following is the link for that.

Get started with ASP.NET MVC and PetaPoco
PetaPoco with stored procedures

Now our customer table is ready. So let’s Create a simple process which will fetch a single customer via CustomerId. Following is a code for that.

CREATE PROCEDURE mysp_GetCustomer @CustomerId as INT AS SELECT * FROM [dbo].Customer where CustomerId=@CustomerId
Now we are ready with our stored procedures. Now lets create code in CustomerDB class to retrieve single customer li…

PetaPoco with stored procedures

In previous post I have written that How we can use PetaPoco with the MVC. One of my dear friend Kirti asked me that How we can use it with Stored procedure. So decided to write a small post for that. So let’s first create a simple stored procedure for customer table which I have used in my previous post. I have written simple code a single query that will return customers. Following is a code for that.

CREATE PROCEDURE mysp_GetCustomers AS SELECT * FROM [dbo].Customer Now our stored procedure is ready so I just need to change my CustomDB file from the my previous post example like following.
using System.Collections.Generic; namespace CodeSimplified.Models { public class CustomerDB { public IEnumerable<Customer> GetCustomers() { var databaseContext = new PetaPoco.Database("MyConnectionString"); return databaseContext.Query<Customer>("exec mysp_GetCustomers"); } } }
That's It. Now It's time t…

Get started with ASP.NET MVC and PetaPoco

Micro ORM are having their pro and cons and right now its a buzz in the Microsoft.NET developers buzz. I personally like a Micro ORM Concept and I already posted some blog posts with mvc and dapper Micro ORM. Today I am going to explain how we can use PetaPoco in mvc application. First lets get little bit introduction about PetaPoco.

PetaPoco is developed by Top Ten software and It’s Micro ORM inspired by Masive and Dapper. Following is link where you can get more information about that.

To install PetaPoco in our application first we need to add a library reference as Its already available there. so Let’s add library reference like following.

Once click on add library reference a dialog box appears to find the the library package like following. I have written PetaPoco in search box and it will be appear in list like following.

Select first one then click Install and It will install the PetaPoco in your application. Once insta…

Tech-Ed on Road 2011- Ahmedabad–A great event

Last Saturday on June 11,2011 Ahmedabad was having Microsoft Tech-Ed on Road event. I was fortunate to being part of it. I have attended many community events in Ahmedabad but this time we get overwhelming response and approx. 300 to 400 persons where there in person and organizers were having hard time to arrange seats for them.

As always first event was started by welcome note where Pinal Dave has delivered a very short and sweet welcome note and then we have got our first speaker Mahesh Dhola on Lightswitch on cloud. In his session he has shown us some excellent features of the Visual Studio Lightswitch . He has created a CRUD Silverlight application without writing zero lines of code and with all the business validation and all the basic stuff that required for a application. The session contained lots practical demos.

After that session we had very own Technology Evangelist Pinal Dave. He has taken session on SQL Server Waits and Queues – Your gateway to performance troublesho…

Important milestone achieved!!- I got 300000 visitors for my blog

I have been writing this blog since last four years and I am working on hard on this to server community which I love most as much as I can. Here I got great news from that my blog has achieved 300000 mark.  I would like to take this opportunity to thanks all my readers who has supported me all time whenever I write blogs. I got some nice appreciations from people and that’s encourage me to write more blogs.

Followings are my statistics from the Till I was writing this blog post I got 304412 visits to my blog and 368759 page views from my blog. Following are screenshots of my statistics.


Here is another one from blogger itself that is saying that I am getting 22500 page views last moth.

When I get appreciation from you guys like this then its feels great. Once this occasion I would like to tell you that if you are having passion for any technologies then please do write blogs. Because you are not going to share it you are not going to gain …