Monday, August 9, 2010

Current Packages for the Nu Package Management

I’ve been doing Rub on Rails now for about 3 months, and I’m really getting into it.  So many nice libraries and conventions to help get applications out the door faster.  Unfortunately my RoR work doesn’t pay the bills yet.  By day I’m a .NET developer.  Recently I came across a blog post written by Ayende Rahien that mentions the use of a new package management utility for .NET developers.  For years Ruby on Rails developers have enjoyed the luxury of installing libraries using the gem utility.  Its really handy to have at your disposal.  Read up on it.  There is now a similar package management utility available for .NET developers called Nu, short for Nubular.  If you read Ayende Rahien’s blog you’ll see how it works.

Current Nu packages are available here

I hope this project catches on and the list continues to grow.  This is going to make things really handy and really quick to get the latest versions of the most common libraries that I use for development.  Best of all now I don’t have to do the package management myself on some file share of mine.

Wednesday, August 4, 2010

Git back here

If you used the git rm command, ignored the warning, you will notice that the file doesn't get removed from your repository, it gets removed from your file system.  There is no trash bin with git either.  You might be in luck if you did a git add first, then issued the git rm command.  Your file will have been hashed and added to the git staging area.  You can retrieve that file by issuing the following command:

git fsck --lost-found

This will pull all the files out of the staging area and drop them in the folder .git/lost-found/other.  One catch though.  The file isn't named as you would think, or hope.  The file is named with its hash value.  This is ok, you haven't lost the contents of the file, just the file name.  If you poke around in the files a bit, you'll find what you are looking for.  Its not perfect, but the content is there.  And yes, I did do this.

Wednesday, June 23, 2010

Uploading files with ASP.NET MVC

Dino Esposito has posted a great article on on how to Upload Files using ASP.NET MVC.  Enjoy.

Saturday, May 22, 2010

Deleting a detached entity with EF4

As unconventional as it may have seemed, it was the reality. With EF1 you had to first query the database to get the entity you wanted to delete. Talk about a waste of time, but the ObjectContext needs to be aware of the entity somehow. In my previous post I talked about how to update a detached entity with EF4. Now deleting a detached entity is just as easy.

void DeleteBook(Book book)
using(var ctx = new BookEntities())

Again pretty easy and should improve on performance.

Updating a detached entity with EF4

With the introduction of EF4 we now have the ability to update entities without having to query the database first. This was always a performance hit with EF1, but a necessary hit. I’m not going to get into that, lets see the code.

void UpdateBook(Book book) {
using(var ctx = new BookEntities()){

Pretty easy. The drawback is that the ChangeObjectState method marks every property of the book object as being Modified. So when EF generates the SQL Update statement, every column in the database for this book record will be updated. This really isn’t an issue if you’ve set all the properties on the book entity. Where it becomes an issue is if you are trying to update only one property. For instance you just want to update book.Title, well if the Title property is the only property you set, then Author, Copyright, NumberOfPages, etc. will all get overwritten with null in the database.