If only I were

Building Great Software

Posts Tagged ‘LINQ

ReSharper 4 EAP – 764

leave a comment »

I just downloaded and installed nightly build 764 of ReSharper 4. I usually don’t go this bleeding edge, but I’m feeling a little dangerous.

Most people I’ve read say that these builds are pretty stable by now. I’ll post with an update by the end of the week.

Written by Chris Sutton

March 29, 2008 at 7:44 pm

Cedar Rapids 2008 Launch Event

leave a comment »

This Monday, March 17th, is our CRIneta.org Visual Studio/SQL Server 2008 Launch Event.  If you want to learn about the new products and you want to have a great time and win from a huge pool of excellent prizes, then go to CRIneta.org and RSVP to be a part of this event.

Tim Barcz, Greg Sohl, Arian Kulp and I are presenting sessions on Visual Studio enhancements, Linq, IIS 7, C# 3, the new .Net Framework features and the new SQL data types.

We have room for 50 people and 38 are RSVP’d already, so don’t wait too long. We are doing the Launch at the Marriott on Collins road in Cedar Rapids. Check the website for more details.

Written by Chris Sutton

March 13, 2008 at 9:18 pm

Iowa Code Camp – Spring 2008

leave a comment »

We are planning our first ever Iowa Code Camp.  It’s going to happen at the University of Iowa’s Conference Center in Iowa City on Saturday May 3rd.

The details are coming together nicely and we already have about 1/2 of our speakers in place.

Our current sponsors are:

  • University of Iowa
  • Microsoft
  • And several others are in the works

We are currently looking for more sponsors to provide some good food, drinks and prizes.

If you are interested in helping in any way, leave me a comment and I’ll make sure to pass your information on to the right person.

Javier has already posted the Code Camp on bostondotnet.org

Clarity with var in C# 3

I was in a class the other day and the instructor introduced the var keyword and then showed us some of the standard fare examples of how to use it.  Then the discussion turned to when to appropriately use var.

An obvious place to use var is when you do a LINQ query and you are selecting a limited set of columns back from the original type:

NorthwindDataContext north = new NorthwindDataContext();
var emps = from e in north.Employees
           where e.City == "London"
           select new { e.FirstName, e.LastName };

There isn’t much choice here since emps is an anonymous type made up of the employee’s FirstName and LastName. The custom or partial projection (everything after the select keyword) forces the result to be an anonymous type.

Then the suggestion came up that you should only use var when you don’t know the type. Here is where I differ in opinion and usage. Look at the following snippet:

using System.ServiceProcess;
var procs = from p in ServiceController.GetServices()
                where p.Status == ServiceControllerStatus.Running
                select p;
procs.ToList().ForEach(p=> Console.WriteLine(p.ServiceName));

procs is certainly IEnumerable<ServiceController> but it doesn’t matter to me. I primarily care that procs is a list and that the individual items in the list have a Property called ServiceName. The underlying type is important to the compiler, but the people that have to read code aren’t compilers right?

I’m very glad that the compiler and runtime do what they do with types, but I want the reader’s focus on the simple LINQ query and iterating over the list it to get a property, not on the type. Replacing var with IEnumerable<ServiceController> is harder to read and less useful.

I think carefully picking your focus can improve your code’s clarity.

Update 5/24/2008: Dare Obasanjo has written one of the best posts expressing caution about abusing var. If var genuinely makes it harder to read your code then you should consider replacing it with an actual type.

Written by Chris Sutton

December 13, 2007 at 10:36 am

Posted in Technology

Tagged with , , ,

ASP.Net MVC Quickstart

with 3 comments

The MVC Toolkit has finally been released as a CTP. Go here to start out – this is the official page with all the links and info you need. Here is the official quickstart link.

kick it on DotNetKicks.com

Update: 1/17/2008

Jeffery Palermo has a great list of his links to get you started.

Links for ASP.Net MVC Reading:

Scott Guthrie is the grandmaster of this project and has posted extensively on different aspects of the MVC framework. Here are some quick links to get you going.

Original post about ASP.Net MVC: http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx

MVC Part 1: http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx

MVC Part 2(URL Routing): http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx

MVC Part 3(Passing ViewData): http://weblogs.asp.net/scottgu/archive/2007/12/06/asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx

MVC Part 4(Form editing and posting): http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-mvc-framework-part-4-handling-form-edit-and-post-scenarios.aspx

Jeffery Palermo of CodeBetter and Party with Palermo Fame has written some about the MVC bits as well. He has an mvccontrib project.  Read about the guidelines for participation.

Rob Conery talks about how to use use a RESTful architecture with ASP.Net MVC.

Nikhil Kothari has a great post showing how to build a basic app.

Links for Listening:

Polymorphic Podcast with Jeffery Palermo: http://polymorphicpodcast.com/shows/aspnetmvc/

If you want the best information on the ASP.Net MVC there are a couple of other people you should be paying attention to: Phil Haack and Fredrik Normén.

I will be updating this post with more information as I find it out.

Well I have some digging to do. I need to get the bits installed for some client work that will be using MVC early next year.


kick it on DotNetKicks.com

Written by Chris Sutton

December 9, 2007 at 9:39 pm

Posted in Uncategorized

Tagged with , , , , , , ,

CRIneta Meeting – Arian Kulp and LINQ

leave a comment »

If you are interested in learning the direction that Microsoft is going with data access you really should come out to our meeting tonight in Cedar Rapids, IA (if you live in the region of course).

Arian Kulp is going to be showing us the ins and outs of how LINQ works – how to query, filter and update data. Btw, Arian wrote the LINQ Hands on Labs for the 2005 PDC, well over 2 years before its official release, and probably long before most of us were aware the technology was being developed.

Written by Chris Sutton

December 3, 2007 at 3:46 pm

Visual Studio 2008 RTM on MSDN – for real

with 2 comments

Frans Bouma says VS 2008 is on MSDN now and Vitaly confirms it.  It’s 7:30am CST and the MSDN download site is already locked up.

As soon as I can get my hands on the bits I have a project to upgrade; I guess I need to make some room on my laptop as well.

Written by Chris Sutton

November 19, 2007 at 7:53 am

Posted in Uncategorized

Tagged with , , , , ,

Visual Studio 2008 RTM

leave a comment »

Update 11/19/2007: Visual Studio has RTM’d now and is available in you MSDN subscriptions.

Through Ben Hoelting through Tim Heuer through Soma the news is that Microsoft will release Visual Studio 2008 by the end of November 2007.  Along with VS 2008 comes .Net 3.5, C# 3.0, VB9, Linq and much more.

The big launch parties and official release are scheduled for early 2008, mainly in February.

kick it on DotNetKicks.com

Written by Chris Sutton

November 5, 2007 at 1:17 pm

Posted in Tech Community, Technology

Tagged with , , ,

First LINQ query expression

leave a comment »

from u in Users
join b in Businesses on u.BusinessID equals b.ID
orderby b.ID
select new {u.LastName, b.BusinessName}

Wow, a basic query expression sure is easy.  And it’s very familiar if you’ve worked with any flavor if SQL. This is an incredibly simple example, but definitely cool.

The order of your clauses definitely shift and your table alias equivalents are a bit different, but barely worth mentioning.

Btw, I’m reading through the .Net Standard Query Operators spec and using LINQPad to get started learning LINQ.  I’ve never met Joseph Albahari, but he seems to be one smart guy.

Written by Chris Sutton

October 10, 2007 at 12:28 pm

Posted in Technology

Tagged with , , ,

Linq and The LINQPad Challenge

leave a comment »

In my quest to learn more about Linq, C# 3.0 and .Net 3.5 I downloaded Joseph Albahari‘s excellent LINQPad. If you look at one of the sections toward the bottom of the LINQPad page you’ll see The LINQPad challenge.  The basic idea is to use LINQPad exclusively for an entire week for all of your querying of SQL Server and by the end of the week you’ll be thinking in LINQ and will likely end up preferring LINQ to T-SQL.

So I’m taking up the challenge.  Version 1.0 of LINQPad has many built in samples that are taken from Joseph’s new book, so this is a good starting point.

I’ll follow up on my findings as I get more into LINQ.

Written by Chris Sutton

October 10, 2007 at 6:59 am

Posted in Technology

Tagged with , ,