Thoughts from Dan Miser RSS 2.0
# Tuesday, February 17, 2009

Ages ago, I wrote about my search for a file sharing application. I eventually went with BeInSync, and used it quite a bit over the past 18 months or so. However, they haven't updated it recently, and there are problems when editing Excel spreadsheets inside the shared folder (I told BeInSync about this problem, they fixed it, and then broke it in the last release). All in all, it was just showing it's age.

Armed with a new set of fairly light requirements (Mac/Windows support, permissions, auto-sync that doesn't fail), I evaluated the space again and came out with a very positive experience of DropBox. It works very well between Mac and Windows, has an awesome web interface, and hasn't exhibited any lags or slowness. In addition, it has the ability to revert to previous versions of documents, which is a nice feature that all developers have come to appreciate.

I'd like to see a couple features in the near future (native iPhone app with support for iWork documents, ability to set your own private key), but this thing was dead simple to install and use, and has worked brilliantly for the past month with a small group of people.

Tuesday, February 17, 2009 1:45:12 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
Macintosh
# Monday, February 02, 2009

I'm using SqlBulkCopy to quickly copy an Excel spreadsheet into MSSQL. It is lightning fast, and works extremely well. One snag came up because I need to have an Identity field for my primary key on this newly copied table (the short story is NHibernate's need for a PK, and the lack of anything resembling a PK in the Excel data due to it coming from legacy data).

The problem is if you add the Identity field in the first column of the destination table, SqlBulkCopy will try to line the columns up by position and things break. You can add ColumnMappings to have SqlBulkCopy write the excel columns to the right MSSQL table column, but that can be a lot of code if you have a lot of columns.

My solution ended up being to simply add the Identity field to the end of the destination table. By doing that, the columns line up during the SqlBulkCopy and everything works just fine.

Monday, February 02, 2009 10:13:23 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
ADO.NET
# Friday, January 30, 2009

At work, a debate broke out over MVC. In that debate, Chris Peterson commented that he hated the way things looked on the view pages, specifically with code executing in the view context. By way of example, he talked about the need for a for loop to display a collection, and how he didn't like that. Geoff Lane commented that Grails had support for this built-in.

To overcome these objections, I wrote the following simple extension method:

public static class RenderPartialCollectionExtension

{

    public static void RenderPartialCollection<T>(this HtmlHelper htmlHelper, string partialViewName, IList<T> list)

    {

        foreach (T item in list)

        {

            htmlHelper.RenderPartial(partialViewName, item);

        }

    }

}

This means that instead of the old-style View page code, like this:

<%

   foreach (Foo foo in Model)

   {

       Html.RenderPartial("~/Partials/DisplayFoo.aspx", foo);

   }

 %>

You can just write code like this:

<% Html.RenderPartialCollection<Foo>("~/Partials/DisplayFoo.aspx", Model); %>

Friday, January 30, 2009 4:40:58 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -
ASP.NET MVC
# Thursday, January 29, 2009

It seems that ASP.NET MVC doesn't allow for strongly-typed partial views. If anyone knows of a clean way to do it, I'd love to know!

Take the following typical page declaration:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Foo>" %>

This declaration allows us to access the Foo.Bar property in the view page using the following syntax: Model.Bar. This works really well, and we even get Intellisense for Foo when accessing the Model property in the editor. In contrast, if we inherited from the non-generic ViewPage, Model becomes a simple object type, which means type-casting to get to our passed in model object.

However, using partial pages with a similar technique does not work. For example, if we have a partial page (ViewPage or ViewUserControl) and call it like below, it will not allow for strong typing of the page:

Html.RenderPartial("DisplayFoo", foo)
If we try to strongly type the page, it will result in an error like this at run-time:
Parser Error Message: Could not load type 'System.Web.Mvc.ViewPage'.

One work-around is to create a code-behind file, and specify the strong typing there, and then inherit the partial page from the code-behind. But I really don't like that. RC1 made great strides to get rid of the code-behind mess, and I would prefer not to reintroduce it just for this.

Update: Thanks to bradleylandis in the ASP.NET MVC forum, he correctly figured out that I had my partial page in a folder other than the Views folder. He mentioned that you need to copy the web.config file from the Views folder to any folder that you serve view pages out of. After doing that, I now have a strongly typed partial page.

Thursday, January 29, 2009 1:22:09 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
ASP.NET MVC
# Wednesday, January 28, 2009

There were a few changes between ASP.NET MVC Beta and RC1 regarding list binding. For background on list binding, look at Phil Haack's excellent article. Here are the changes that I saw, some good, and some bad:

  • You no longer need to specify the ".index" hidden field. This is good, as it's one less hidden field to take care of.
  • Binding occurs automatically for lists of complex types, but you must have contiguous numbering of the elements, starting with zero. This means that you can no longer specify the index with things like key information. I'm not wild about this change.
  • In the Beta release, binding would only occur for properties of IList. I've been using LightSpeed lately, and that means my property looks like this: EntityCollection<FooType> FooProperty. EntityCollection supports IList, but because it wasn't truly an IList in the class declaration, the default binding didn't work. In the Beta release, I got around this by adding a mirrored property of IList<FooType> and then copying the data over to FooProperty in my controller method.
  • Nested property references, e.g. Foo.Bar, now get the resulting input id renamed to Foo_Bar. This makes it easier to work with jQuery selectors on these elements.

All in all, I'm really liking the RC1 release. I'm looking forward to the release!

Wednesday, January 28, 2009 6:04:53 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -
ASP.NET
# Thursday, October 02, 2008

I'll be out in L.A. for PDC 10/25-10/30. If you're going to be there, too, drop me an email!

Thursday, October 02, 2008 10:22:41 AM (Central Daylight Time, UTC-05:00)  #    Comments [0] -
.NET
# Monday, September 29, 2008

Please RSVP to dmiser@wi.rr.com ASAP if you plan on making this Wednesday's ALT.NET meeting, where we can hopefully cover mocking.

When: 10/1/08 @ 7pm

Where: 10000 Innovation Drive, Suite 260 (SpiderLogic office)
Monday, September 29, 2008 9:58:05 AM (Central Daylight Time, UTC-05:00)  #    Comments [0] -
ALT.NET
# Wednesday, September 03, 2008

Due to lack of responses, I'm canceling the ALT.NET meeting for tonight. Please mark your calendars for Wednesday, 10/1/08 for the next meeting, where we will try to cover mocking.

 

Please send me an email at dmiser@distribucon.com if you plan on making it in October.

Wednesday, September 03, 2008 11:19:19 AM (Central Daylight Time, UTC-05:00)  #    Comments [1] -
ALT.NET
# Wednesday, August 27, 2008

Now that summer is drawing to a close, it's time to think about a meeting of the Milwaukee ALT.NET minds again.

When: Wednesday, September 3rd, 2008 @ 7pm
Where: 10000 Innovation Drive, Suite 260 (SpiderLogic office)

I'm hoping that the topic will be mocking, but I'm open to other suggestions.

If you can RSVP by sending an email to me at dmiser@distribucon.com, I'd appreciate it. That way, we can start to get a handle on head count and have enough food on hand for everyone. Thanks, and hope to see you there.

Wednesday, August 27, 2008 11:27:43 AM (Central Daylight Time, UTC-05:00)  #    Comments [0] -
ALT.NET
Navigation
Archive
<February 2009>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)