Wow. Impressive! Great for quick and dirty stuff, no? It uses dynamic types extensively.
dapper-dot-net - Simple SQL object mapper for SQL Server - Google Project Hosting: "Dapper - a simple object mapper for .Net
Dapper is a single file you can drop in to your project that will extend your IDbConnection interface."
This is just a spot to keep miscellaneous links. It also shows you what a geek I am.
Monday, April 04, 2011
Friday, April 01, 2011
Setting the Text of a ListControl in ASP.NET
If you try the following, it should set the visible text of the dropdown control in question, right?
You may be asking yourself why I am trying to set the visible text and not the value of the control. The reason is that the application I'm working on receives the displayed text from a web service and not the value that is passed in the form variables. Why not create a dictionary, look up the the text string in the dictionary, and pass that to the control?
The answer? I already have a dictionary. It's called the SELECT control itself. The generated HTML for my control is, say, the following:
This control is essentially a dictionary of key-value pairs: the key is the value attribute of the option tag, and the value is the visible text that is displayed for the given item in the dropdown list. So in the spirit of Don't Repeat Yourself (DRY), I wrote a extension function to allow me to set not just the value but also the text. I give you ListControlExtensions.cs:
Here's a typical usage. In this particular scenario, my data should be scrubbed, but if not I log a warning:
listControl.Text = "4 Year College";Well, unfortunately, no! The "Text" property is named that way for consistency across all ASP.NET controls and refers to the form value that is passed to the server when the page is submitted. So unfortunately for me, the "Text" property silently rejected my attempt to set it and the page did not work.You may be asking yourself why I am trying to set the visible text and not the value of the control. The reason is that the application I'm working on receives the displayed text from a web service and not the value that is passed in the form variables. Why not create a dictionary, look up the the text string in the dictionary, and pass that to the control?
The answer? I already have a dictionary. It's called the SELECT control itself. The generated HTML for my control is, say, the following:
This control is essentially a dictionary of key-value pairs: the key is the value attribute of the option tag, and the value is the visible text that is displayed for the given item in the dropdown list. So in the spirit of Don't Repeat Yourself (DRY), I wrote a extension function to allow me to set not just the value but also the text. I give you ListControlExtensions.cs:
Here's a typical usage. In this particular scenario, my data should be scrubbed, but if not I log a warning:
Monday, March 28, 2011
Five advanced Git merge techniques : Inside P4
Includes the handy-dandy command: git config --global merge.conflictstyle diff3
by Edward Z. Yang
Have you ever performed a merge in Git and not have it quite turn out the way you wanted it to? For example, you accidentally converted all of your UNIX line endings to DOS line endings, and now the entire file reports a conflict? Maybe you see a conflict that you don't really care about resolving, and want to resolve as theirs? Or perhaps the conflicted file is empty and you can't figure out just what happened there?"
Friday, March 25, 2011
Caffeine-Powered Life - Nested Collection Models in ASP.NET MVC 3
Wow! Caffeine-Powered Life - Nested Collection Models in ASP.NET MVC 3: "We want to create form where I can save information about a person. That person has zero or more phone numbers and zero or more email addresses. The customer would like to edit everything about a person all at once, on a single form. This is a dynamic nested model problem."
Saturday, March 19, 2011
IIS Express FAQ : IIS Express : Microsoft Web Platform : The Official Microsoft IIS Site
After I relocated an IIS express application, it stopped working. Even though I re-registered it with Visual Studio, it appeared "stuck" in its old location. The problem is that Visual Studio doesn't tell you that it hasn't really done anything at all when it claims that it's successfully registered your app after you've moved it. After reading this FAQ I was able to delete the broken site registration and then re-add it in Visual Studio. To fix my problem, I ran "%userprofile%\documents\IISexpress\config" from the Windows start menu, did a ctrl-F to find the application name, and simply deleted the configuration node.
A: Yes, IIS Express uses the same applicationhost.config and web.config files supported by IIS 7.x. The key difference is that with IIS Express, the configuration is maintained on a per-user basis. In particular, whereas IIS has a global “applicationhost.config” file, IIS Express maintains a user-specific “applicationhost.config” file in the %userprofile%\documents\IISexpress\config” folder. This lets a standard user run IIS Express and also lets multiple users work on the same machine independently, without conflicting with each other. Some settings require Administrator user rights to set and modify (see question above about running as a standard user)."
Thursday, March 10, 2011
Tuesday, February 22, 2011
Sunday, February 20, 2011
Reimplementing LINQ to Objects: Part 43 - Out-of-process queries with IQueryable - Jon Skeet: Coding Blog
Reimplementing LINQ to Objects: Part 43 - Out-of-process queries with IQueryable - Jon Skeet: Coding Blog
Interesting stuff throughout, but here's the summary at the end:
"This was really a whistlestop tour of the "other" side of LINQ - and without going into any of the details of the real providers such as LINQ to SQL. However, I hope it's given you enough of a flavour for what's going on to appreciate the general design. Highlights:
- Expression trees are used to capture logic in a data structure which can be examined relatively easily at execution time
- Lambda expressions can be converted into expression trees as well as delegates
- IQueryable
and IQueryable form a sort of parallel interface hierarchy to IEnumerable and IEnumerable - although the queryable forms extend the enumerable forms - IQueryProvider enables one query to be built based on another, or executed immediately where appropriate
- Queryable provides equivalent extension methods to most of the Enumerable LINQ operators, except that it uses IQueryable
sources and expression trees instead of delegates - Queryable doesn't handle the queries itself at all; it simply records what's been called and delegates the real processing to the query provider"
Reimplementing LINQ to Objects: Part 43 - Out-of-process queries with IQueryable - Jon Skeet: Coding Blog
Reimplementing LINQ to Objects: Part 43 - Out-of-process queries with IQueryable - Jon Skeet: Coding Blog
Interesting stuff throughout, but here's the summary at the end:
"This was really a whistlestop tour of the "other" side of LINQ - and without going into any of the details of the real providers such as LINQ to SQL. However, I hope it's given you enough of a flavour for what's going on to appreciate the general design. Highlights:
- Expression trees are used to capture logic in a data structure which can be examined relatively easily at execution time
- Lambda expressions can be converted into expression trees as well as delegates
- IQueryable
and IQueryable form a sort of parallel interface hierarchy to IEnumerable and IEnumerable - although the queryable forms extend the enumerable forms - IQueryProvider enables one query to be built based on another, or executed immediately where appropriate
- Queryable provides equivalent extension methods to most of the Enumerable LINQ operators, except that it uses IQueryable
sources and expression trees instead of delegates - Queryable doesn't handle the queries itself at all; it simply records what's been called and delegates the real processing to the query provider"
Friday, February 18, 2011
Formula for computing how many end users to interview
From http://www.measuringusability.com/blog/customers-observe.php:
We went to a customer's house or workplace and watched them do what they do and recorded their behavior and problems they encountered and how they solved them. Data from follow-me-homes were used for new product ideas and improving existing products. "
"Stalking Customers
When I worked at Intuit (makers of TurboTax, Quicken & QuickBooks) we used a method called "follow-me-home." It was as effective as it was simple in identifying customer problems and needs.We went to a customer's house or workplace and watched them do what they do and recorded their behavior and problems they encountered and how they solved them. Data from follow-me-homes were used for new product ideas and improving existing products. "
Tuesday, February 15, 2011
Scott Hanselman - Creating a NuGet Package in 7 easy steps - Plus using NuGet to integrate ASP.NET MVC 3 into existing Web Forms applications
Scott Hanselman - Creating a NuGet Package in 7 easy steps - Plus using NuGet to integrate ASP.NET MVC 3 into existing Web Forms applications
Also my comment on how to wire up the resultant .csproj file to have the MVC context menus:
Woot! I added the GUID {E53F8FEA-EAE0-44A6-8774-FFD645390401} to the ProjectTypeGuids node of the .csproj, and it's a bone fide MFC project with context menus in the Solution Explorer.
This is the result, with the new GUID underlined:
{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
Also my comment on how to wire up the resultant .csproj file to have the MVC context menus:
Woot! I added the GUID {E53F8FEA-EAE0-44A6-8774-FFD645390401} to the ProjectTypeGuids node of the .csproj, and it's a bone fide MFC project with context menus in the Solution Explorer.
This is the result, with the new GUID underlined:
Wednesday, February 09, 2011
The perils of using Func instead of Expression in an IQueryable
This is sort of a LINQ 101 thing, but I haven't had much of an opportunity to use LINQ to SQL yet, believe it or not.
I learned the hard way: when using IQueryable against a database, any predicates handed around should be Expression<func<type, bool>> instead of just Func<type, bool>. Func<type, bool> is evaluated in memory! That means that the entire table is fetched from the database, then filtered in memory. Bad, bad, bad!
I learned the hard way: when using IQueryable against a database, any predicates handed around should be Expression<func<type, bool>> instead of just Func<type, bool>. Func<type, bool> is evaluated in memory! That means that the entire table is fetched from the database, then filtered in memory. Bad, bad, bad!
Friday, February 04, 2011
Video Series: How To Give Great Presentations
Video Series: How To Give Great Presentations: "UGSS (Microsoft's User Group Support Services) have just published a video series that I recorded last year on How To Give Great Presentations. This free series of 8 videos covers the following subjects:-"
Friday, January 21, 2011
Scaffold your ASP.NET MVC 3 project with the MvcScaffolding package « Steve Sanderson’s blog
Very cool. This thing will generated CRUD support, list views, etc.
How To Use Amazon EC2 as Your Desktop - RestBackup™ Blog
How To Use Amazon EC2 as Your Desktop - RestBackup™ Blog: "In this article, I describe how I use EC2 as my Linux development desktop. I provide detailed instructions for every step of the setup process. This guide assumes that your client machine is Windows."
Scott Hanselman - Link Rollup: New Documentation and Tutorials from Web Platform and Tools
Scott Hanselman - Link Rollup: New Documentation and Tutorials from Web Platform and Tools:
"Intro to ASP.NET MVC 3 onboarding series.
Scott Hanselman and Rick Anderson collaboration and Mike Pope (Editor)
Both C# and VB versions:
- Intro to ASP.NET MVC 3
- Adding a Controller
- Adding a View
- Entity Framework Code-First Development
- Accessing your Model's Data from a Controller
- Adding a Create Method and Create View
- Adding Validation to the Model
- Adding a New Field to the Movie Model and Table
- Implementing Edit, Details and Delete
- Source code for this series"