The opinions expressed in these materials are my own and are not necessarily those of Microsoft.
Copyright © Microsoft Corporation. All rights reserved. Unless otherwise indicated, all source code provided is licensed under the Microsoft Public License (Ms-PL).
Well! I had an interesting night. As many of probably know by now we have four dogs at my house: Max (Basenji), Fibi (Jack Russell Terrier), Lily aka Piggy (we think she is a Pit Bull mix), and Zorro (Blue Tick mix). With four dogs you are always breaking up little fights between them at one time or another. Not sure if it is just our dogs or this is a normal thing.
Last night my dogs were in the backyard and I heard a little skirmish start. I did my usual yell to tell them to cut it out but this time Zorro kept making a funny noise like he was hurt. It didn't sound good at all. I went out side and found Max and Zorro attacking Lilly. Normally Lilly can handle herself no problem but she didn't seem to be fighting and it looked like Zorro had her around the neck.
As I approached and got Zorro to hold still I discovered that he had managed to get his lower jaw stuck in Lilly's collar. As I looked closer I found I was having a hard time getting Zorro lose so I brought them closer into the light near our porch. That is when I realized there was a bad problem. Zorro was really stuck and there was blood all over Lilly.
I called for my wife to come down and give me some help and she began looking for a flashlight to get a better idea of what we were dealing with. Right after she left, I noticed that Lilly had a funny look and realized she was choking--things were much worse than I thought. OMG. I almost freaked but held it together and called for my wife to bring me a knife (screw the collar, ill buy a new one). It was close but I managed to cut the collar off w/o cutting Zorro or Lilly. As soon as I cut them lose, I grabbed Lilly who had turned purple and had stopped breathing.
I didn't know you could give a dog mouth-to-mouth but my wife (freaking out) managed to say "give her mouth-to-mouth". Now, I have to admit, giving my dog mouth-to-mouth was not appealing to me but when you are faced with a purple dog you tend to not give a crap. I directed her to start the car so we could take Lilly to the emergency room and gave the the dog mouth-to-mouth.
It worked! I never, EVER would have thought you could resuscitate a dog that way but she started breathing slowly and we rushed her to the emergency room. By the time we got to the emergency room, she had completely restored breathing and was just a regular dog. So there we were in our pajamas with a perfectly healthy dog just wagging it's tail and having a good time. About 30 minutes and 95 dollars later we were on our way home and now we are looking for a new (hopefully safer) collar for Lilly. :P
Okay so last quarter I was asked if you can call stored procedures using Language Integrated Query (LINQ). The answer, of course, is YES! It would be kind of silly if we didn't include this type of functionality. :P
NOTE: You need the following items to do this example
SQL Server (pretty much any version will do but this example uses 2005)
Visual Studio 2008 (Beta 2 was used for this example)
A little time to sling some code
So how exactly DO you call a stored proc using LINQ? Easy just follow these simple steps:
Menu: Tools -> Options -> Projects and Solutions –> General Commands: View.TrackActivityinSolutionExplorer Versions: 2005,2008, 2010 Published: 3/29/2010 Code: vstipProj0011
Note: Several people have asked if you can turn this feature on and off at will. You can if you bind the View.TrackActivityinSolutionExplorer command to a keyboard shortcut.
By default, VS2010 will track the current file you are editing in Solution Explorer. It looks like this:
Notice that the current file being edited is also selected in Solution Explorer automatically. This is a great way to keep track of where you are in the solution when you are working with a lot of files. You can turn it off if you want. Just go to Tools -> Options -> Projects and Solutions -> General -> "Track Active Item in Solution Explorer" and uncheck the option to turn this feature off.
Keyboard: CTRL + K, CTRL + K (toggle bookmark)Menu: Edit -> Bookmarks -> Toggle BookmarkCommand: Edit.ToggleBookmarkVersions: 2008,2010Published: 7/5/2010Code: vstipTool0047
Bookmarks are a pretty cool feature that a lot of people don't seem to know about. Essentially, Bookmarks are a way to mark locations in your code. Unlike tokens ("TODO's"), Bookmarks are not stored with the source code. There are numerous ways to set a Bookmark. The simplest way is to use CTRL + K, CTRL + K to create a single Bookmark:
When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window:
The good news is you don't have to keep the default name that is given for the Bookmark. Just RIGHT CLICK the entry in the window and choose "Rename":
Then put in whatever you want for the name and you are good to go:
You can continue to use this method or the menu to create Bookmarks. Another cool way to create Bookmarks is to use the "Bookmark All" (bottom right) button in the Quick Find dialog (CTRL + F):
[EDIT: As Guy pointed out on his blog http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/11/19/visual-studio-2008-rtm-is-available-for-msdn-subscribers.aspx VS2008 is RTM for MSDN already]
By now it is no secret that Visual Studio 2008 will RTM before the end of November. Soma mentioned this at TechEd Europe and I couldn't be more excited! Make sure you are getting ready with for the new version by checking out our webcasts and other training materials that are available. Here is a list of places to help you get prepared:
Main Visual Studio 2008 Product Page http://msdn2.microsoft.com/en-us/vstudio/products/default.aspx
Main World Wide Events Website http://msevents.microsoft.com/cui/default.aspx?culture=en-US
NOTE: Don't let the name throw you off, this is your best "one stop shop" for getting MS content. Make sure to take advantage of the Virtual Labs! Below is an extremely short list at what I found when I searched on the keyword "linq":
Channel 9 (of course) http://channel9.msdn.com/
And of course the various blogs (on the left hand side) and other resources that crop up. I will be doing a 26 part webcast on new features of VS2008 beginning in December as well.
In the meantime, let's have a contest. Post here with your list of resources for getting up to speed with VS2008. I will randomly choose one person to be the recipient of ONE of these prizes (winner's choice):
Windows Vista Ultimate
Office 2007 Ultimate
Halo 3/Flight Simulator X Combo gift
[Edit: contest extended until 12/1 by popular demand!]
Just in time for the holidays! Contest ends on 11/26/2007 @ 5pm Central. Good Times :)
(MS employees not eligible but shoot me an email if you would like to see an FTE version of this contest)
Keyboard: CTRL + M, CTRL + M Menu: Edit -> Outlining -> Toggle Outlining Expansion Command: Edit.ToggleOutliningExpansion Versions: 2008,2010Published: 3/15/2010Code: vstipEdit0029
By default, Outlining is enabled in Visual Studio. It's the line you see with the boxes to indicate the status of the area (collapsed or expanded):
You can collapse areas of code to get them out of your way so you can focus on other areas. There are four ways to do it:
Once collapsed, the code area will look like this:
This week I thought we would focus on some fun quickies that have been in Visual Studio since at least VS2010. The first one we will look at is simply zooming your text in the editor. The concept is really simple. For example, you may want to go from this:
Being able to zoom in and out is useful if you have trouble seeing or you are doing extreme programming or any situation where making text more readable is necessary. One other thing to keep in mind is that zooming is a per tab activity so zooming in one tab does not set the same zoom level in other tabs. Each tab has it's own zoom level.
You can zoom in and out of text using the wheel on your mouse. Just hold down CTRL+Mouse Wheel and you can instantly zoom in and out of text in the editor.
Most people discover this accidentally. If this annoys you then you can see if there is an update to the Disable Mouse Wheel Zoom extension:
At the time of writing there isn’t a version that works with VS2013 but that could change.
You can go “old school” and use the combo box at the bottom left of the IDE:
If you prefer to use the keyboard, you can always use CTRL+SHIFT+>[Greater Than] and CTRL+SHIFT+<[Less Than].
NOTE: This is an older feature. I’ve updated the information for VS2013.
This one is a little known feature you can take advantage of when working with your code. Assuming you have some unformatted code:
You can format the entire document by going to Edit -> Advanced -> Format Document (CTRL+K, CTRL+D) to get this:
You can also do this with just a selection of code:
Go to Edit -> Advanced -> Format Selection (CTRL+K, CTRL+F) to get this:
I won’t go deep into it here but it’s important to remember that the automated formatting follows the default rules you can easily change by going to Tools | Options | Text Editor | [Language] | Formatting in most cases. For example, to change the HTML rules go to Tools | Options | Text Editor | HTML | Formatting:
In the case of HTML, you can go pretty deep into the formatting options by clicking on the Tag Specific Options button:
Formatting the document or selection is a great way to make your code more readable. Enjoy!
Menu: Project -> Add New Solution Folder; [Right-Click Solution] -> Add -> New Solution Folder Command: Project.AddNewSolutionFolderVersions: 2008,2010Published: 3/27/2010 Code: vstipProj0009
Did you know there are special folders to help you organize large solutions? There is! They are called, appropriately enough, Solution Folders. To create one just Right-Click on your solution (or go to Project -> Add New Solution Folder) and you will see this in Solution Explorer:
Simply give the folder a name and you are good to go. But so what? I mean, what can you actually DO with these things? Here is a list of stuff you can do:
Move or add projects to them. Solution Folders can be nested to create greater organizational structure.
Add, delete, or rename Solution Folders at any time, if the organizational requirements of the solution change.
Unload all projects in a Solution Folder to make them temporarily unavailable for building.
Collapse or hide entire Solution Folders so that you can work more easily in Solution Explorer. Hidden projects are built when you build the solution.
Build or rebuild all the projects. The projects are built in the order specified by the project dependencies.
Solution Folders are an organizational tool in Solution Explorer; corresponding Windows folders are not created. Microsoft recommends that you organize your projects on disk in the same way that you organize them in the solution. But that is your call :)
Shoot me the URL to your blog and point out where you have linked to me. I will pick one lucky victim...er...winner to reward with a Visual Studio 2008 Backpack or 3 Visual Studio T-Shirts.