Archive for the ‘Programming’ Category

LINQ to SQL in SQL Server

I’m writing some code that will be in a .NET 3.5 assembly running in SQL Server 2005. Since I’ll need to retrieve data from the database, I figured I might as well try out LINQ to SQL running inside SQL Server while I’m at it. The good news is that it will work, however you will have to add a couple more assemblies into SQL Server than just your assembly.

This post won’t go through the basics of SQLCLR integration. You can read about SQLCLR in this super long MSDN article or these 2 short and succinct articles instead (TIP: take the 2 short articles :P ).

So to get LINQ to SQL working inside SQL Server 2005, you’ll need to add the following assemblies first (shown in hierarchical dependence order):

  • System.Core
  • System.Data.Linq
    • System.Runtime.Serialization
      • SMDiagnostics

Run the following script to register these assemblies (assuming default installation locations):

CREATE ASSEMBLY [SMDiagnostics]
AUTHORIZATION dbo
FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\SMDiagnostics.dll'
WITH permission_set = unsafe

CREATE ASSEMBLY [System.Runtime.Serialization]
AUTHORIZATION dbo
FROM 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll'
WITH permission_set = unsafe

CREATE ASSEMBLY [System.Data.Linq]
AUTHORIZATION dbo
FROM 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll'
WITH permission_set = unsafe

CREATE ASSEMBLY [System.Core]
AUTHORIZATION dbo
FROM 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\system.core.dll'
WITH permission_set = unsafe

Once these assemblies are in SQL Server, you’ll be able to add your LINQ-ified assembly into SQL Server.

With all those assembly registrations, is it worth it? I don’t think so. After I tested it out, I got rid of all those assemblies and replaced my LINQ code with a few simple calls to SqlCommand to get my small piece of data. This just goes to show you: the newest technology is not necessarily the best technology. Don’t just blindly follow whatever is the latest that Microsoft pitches to you!

No Comments


Watching a random user use Vista

image from http://www.desk-trainer.com/ I was sitting in the library earlier today when I noticed someone sitting in front of me with her computer on. While laptops in the library are commonplace these days, what was especially interesting about her computer was that it was running Vista. So out of curiosity, I decided to watch Jane Doe for a few minutes to see what her experience with Vista was like (Yes I’m nosy, but this is for an educational experiment. :P  And if you’re the person who I was watching, I apologize. Don’t worry, I was too far to see anything meaningful! :) ).

Jane had a Sony laptop running Vista Premium. Let’s see what she was doing while I was watching:

1. Getting Connected

Shi Da (師大) has a wireless network across campus. The first thing I saw Jane do was try to get connected to the wireless network. She stayed on the wireless network dialog for a while (probably a good 2 minutes), which I’m guessing because the connection wasn’t connecting.

2. Media Player

After getting connected, she restored an already open Windows Media Player window which means she was listening to music. I noticed headphones on so that seemed like a valid assumption.

3. Messenger

Of course who doesn’t use IM these days? She popped open MSN messenger next to check on who’s online… well that was the original intention at least. The window stopped functioning during login and then the crashed dialog opened up showing the window had stopped functioning. I couldn’t see which option she clicked, but the progress bar started going afterwards.

4. Browser

Jane opened up an Internet Explorer window, but unfortunately this one also stopped functioning. She typed, clicked on the window without any response. Then the crashed dialog opened up showing the window stopped accepting input from the user. She clicked it and the progress bar started again.

5. Waiting

She went back to her studies while waiting for the close dialog to turn off. About 3 minutes later they finally closed. She opened up another browser window and this time no crashes. She typed in Facebook’s URL and started checking someone’s profile (couldn’t see from where I was sitting).

6. Torrents

She opened up another browser and this time opened up a torrent tracking site. She downloaded a torrent and started downloading some file (once again, couldn’t see exactly from where I was sitting).

7. Switching back and forth

For the next few minutes, Jane switched back from Facebook, to Media Player, torrent status, and back to Facebook.

8. Back to networking

About 5 minutes later, the browser stopped loading web pages. So she went back to the wireless network dialog to check on the network status. About 30 seconds later, the network was back up so she went back to Facebook.

At this point, I stopped watching as she was just browsing Facebook now.

One question comes into mind: did she use any of the “new” features of Vista? Absolutely not. Everything that I watched her do on her computer, XP could have handled perfectly if not better than the Vista equivalents. For example, the sidebar was left in the default state with the picture and clock gadget. The sidebar was left uncustomized and was just sitting there taking up screen real estate. Flip3D? Might as well not exist as she used the task bar to change windows.

So what did I learn from watching this random computer user using her computer running Vista for a couple of minutes? I learned that the flashy Vista or the new UI means nothing to the user. The user only wants to be able to accomplish a task: chat, read web sites, listen to music, …. While I learned this lesson previously through my past work experience, watching this random user today just reinforced this idea in my mind. I believe all software developers should watch a user use a computer before programming professionally. Of course I mean a “typical” user, not your project partner who’s hacking away at a bash script. ;) Watching a user gives a lot of insight into how to design software for the user and not for the programmer.

No Comments



SetPageWidth