Skip to content

A Handy Refactoring with CodeRush (InLine Temp)

Updated: at 02:12 PM

I’ve recently started using CodeRush with Visual Studio 2010 and am so far very impressed with the convenience it adds to coding.  One thing that is very clear is that the creators of CodeRush are real programmers and look very hard for patterns that us developers are constantly doing.  As I run into these things that get my attention, I plan on blogging them.  Some are just earth shattering, and others, just nice to have.  This particular one is a nice to have.

So, say you have code like this:


var sessionAttendeeOds = 
new SessionAttendeeODS();
listSessionAttendees =

When I first wrote code, I often do it like this thinking that I may have more methods I’m going to call against the instantiated object.  In this case, many years later, I’m looking at the code and want to condense it.  With CodeRush, it show me three little dots under the variable sessionAttendeeOds as follows.  When I click on these three dots, I get the following screen.


When I chose “InlineTemp”, the code changes to the following, make it easier to read.

listSessionAttendees = 
new SessionAttendeeODS().GetByUsername(Context.User.Identity.Name);

Again, this is not a huge deal, but small fixes like this will add up over time and make my code cleaner and more readable.  CodeRush makes it so easy that I’m sure I’ll do this kind of thing more and more.


Check out the ORM (Object Relational Mapper) PRISMA. The database access method I use in all my projects