June 02, 2008

Things I learned this weekend

Wield Chkdsk sparingly

Do not set large hard drives (and especially not two large hard drives) to run an error check (chkdsk) on next reboot if:

  • your PC only supports USB keyboards and
  • your PC's bios does not support "Legacy USB settings" and
  • you've never installed the Recovery Console to your PC.

You'll have no way to cancel the chkdsk* and you'll have to wait several (like 12+) hours for it to complete. No, regular Safe Mode doesn't help, because it still tries to run chkdsk before booting the OS.

* - "no way" technically is not correct. If you had another OS installed then you may be able to boot into it and update the dirty flags on the hard drives so you could get around the chkdsk. Something like a Live CD from a Linux distribution might work. I'm sure there are other alternatives as well. "no way that the average PC user would consider easy" is probably the proper phrasing.

LINQ to SQL is gooood!

  • LINQ to SQL creates SQL just as good as I would write by hand, and most of the times better, and sometimes much better.
  • LINQPad = For The WIN !!!
  • To gain a better understanding of LINQ to SQL use LINQPad to see what the query syntax looks like as Lambda syntax and SQL Profiler (and/or LINQPad) to see the SQL being generated.
  • You can pass IQueryable around as many times as you want and the SQL is never executed until its turned into a list (think used as a datasource even if ToList() is not specifically called). I had a tough time wrapping my head around this one - SQL Profiler helped prove it to me.
  • The new ListView + the new DataPager + LINQ = beautiful music
  • Between LINQ to SQL, Subsonic, and Castle ActiveRecord I may never hand-code another line of SQL ever again.

Miscellaneous

  • The installation of VS 2008 to my workstation was nowhere near as difficult as I'd feared it to be. As far as I can tell it didn't muck anything up.
  • GraphJam is hilarious
  • a Sunday afternoon nap is not a blessing, it is a right !

Comments,

  • Trackbacks,
  • and Pingbacks
  1. If I never had to write another line of SQL, I'd be a very happy man.

    Have you seen any memory issues running LINQ in loops? We're seeing some pretty serious problems which is really making us 2nd guess. Outside of loops, it's a no brainer...but we're baffled as to why we're seeing what we're seeing when running LINQ commands in loops.

  2. Jayson, my LINQ experience has been limited to about 8 hours of just learning some basics and using it for one small example. I had a site where I needed to add some paging to records being returned to a page and I knew LINQ, ListView, and DataPager had a good story for that. I just changed a couple of my Data Access methods to use LINQ to SQL rather than some hard-coded ADO.NET code and it worked fine. It is a small scale site (only about 10 unique users per day) and it is only used in a couple of places. I definitely don't have enough experience yet to comment on performance implications. But I love the developer story so far !!

  3.  avatar James Curran says:

    Another cool IQueryable<> trick:  While you are passing it around, you can modify it:

    var q = from p in db.Person

           where p.State = "NJ";

    if (age != 0)

        q = q.Where(p=> p.Age > age);

    if (salary !=0)

        q = q.Where(p=> p.Salary > salary);

    if (desc)

        q = q.OrderByDescending(p=>p.LastName);

    else

        q = q.OrderBy(p=>p.LastName);

  4. James, we're on the exact same page! That is exactly what I was doing with IQueryable. I had updated my data layer to return IQueryable rather than the DataTable it was returning previously. Then at a higher level I was modifying it by using Skip() and Take() to implement some paging and doing some different sorting in different places.

    My initial concern (because I hadn't worked with IQueryable or LINQ at all before) was that SQL queries were being made when the IQueryable was first created and passed and then again when I did the Skip and Take. SQL Profiler proved to me that it wasn't. And I learned the beauty of IQueryable!!

  5. Hey Dan,

    LinqPad is great. Thanks for posting about it. I'd been meaning to learn more about Linq, and this is an excellent resource.

  6. Thanks, Chris. I took a look at LinqPad based on the recommendation of others. I have only played around with it for a couple of hours last weekend, but in that short time I found it invaluable, especially when just starting out with LINQ.

  7. I'm going to second Chris, thanks for posting about LINQpad. Now I can actually learn LINQ while still being stuck in .NET 2.0.

Comments are closed.

 

Trackbacks and Pingbacks


  1. TrackBack says:
Shortcuts

Where is Dan?


My Blog
My Blog
Twitter
Twitter
Facebook
Facebook
LinkedIn
LinkedIn
Flickr
Flickr
YouTube
YouTube
Delicious
Delicious
Foursquare
Foursquare
Pinterest
Pinterest
GetGlue
GetGlue
Pintley
Pintley
XBOX Live
XBOX Live
Last.fm
Last.fm
Windows Live
Windows Live
Telligent.com
Telligent
Graffiti CMS on CodePlex
Graffiti CMS
Popular

Recent Posts