Browsing Tag »Source Code«

The Weekly Source Code 56 – Visual Studio 2010 and .NET Framework 4 Training Kit – Code Contracts, Parallel Framework and COM Interop

August 12, 2010

Do you like a big pile of source code? Well, there is an imperial buttload of source in the Visual Studio 2010 and .NET Framework 4 Training Kit . It's actually a 178 meg download, which is insane. Perhaps start your download now and get it in the morning when you get up. It's extremely well put together and I say Kudos to the folks that did it. They are better people than I. I like to explore it while watching TV myself and found myself looking through tonight. I checked my blog and while I thought I'd shared this with you before, Dear Reader, I hadn't. My bad, because it's pure gold . With C# and VB, natch. Here's an outline of what's inside. I've heard of folks setting up lunch-time study groups and going through...(read more)

The Weekly Source Code 52 – You get using that LINQ, I dunna think it means what you think it means.

June 18, 2010

Remember good developers don't just write source code, they also READ it. You don't just become a great poet by writing lots of poems. Read and absorb as well. Do check out the Source Code category of my blog here , there's (as of today) 15 pages of posts on Source Code you can check out. Recently my friend Jonathan Carter (OData Dude, my name for him) was working with a partner on some really weird stuff that was happening with a LINQ to SQL query. Remember that every abstraction sometimes leaks and that the whole port of an abstraction is "raise the level" so you don't have to worry about something. Plumbing is great because it abstracts away water delivery. For all I know, there's a dude with a bucket who runs...(read more)

The Weekly Source Code 52 – You keep using that LINQ, I dunna think it means what you think it means.

June 18, 2010

Remember good developers don't just write source code, they also READ it. You don't just become a great poet by writing lots of poems. Read and absorb as well. Do check out the Source Code category of my blog here , there's (as of today) 15 pages of posts on Source Code you can check out. Recently my friend Jonathan Carter (OData Dude, my name for him) was working with a partner on some really weird stuff that was happening with a LINQ to SQL query. Remember that every abstraction sometimes leaks and that the whole port of an abstraction is "raise the level" so you don't have to worry about something. Plumbing is great because it abstracts away water delivery. For all I know, there's a dude with a bucket who runs...(read more)

Extending NerdDinner: Exploring Different Database Options

May 20, 2010

The original NerdDinner Sample was very simple. Two samples, simple, in fact. Perhaps it's the new Northwind, as it's a good way to start working with ASP.NET MVC. However, it's not a perfect sample or an idealized example on how to do many things that users want to do. Fortunately, there's been lots of cool folks in the community who have "forked" NerdDinner and done interesting stuff with it. Each of these samples is usually focused on a specific scenario, so they won't necessarily be merged with the trunk, but they are educational nonetheless. Four Five NerdDinners - Each Accessing Data Differently When NerdDinner was originally done, I did it in Linq To SQL as L2S was fast, easy, had a 1:1 relationship between...(read more)

Extending NerdDinner: Adding MEF and plugins to ASP.NET MVC

May 20, 2010

The original NerdDinner Sample was very simple. Two samples, simple, in fact. Perhaps it's the new Northwind, as it's a good way to start working with ASP.NET MVC. However, it's not a perfect sample or an idealized example on how to do many things that users want to do. Fortunately, there's been lots of cool folks in the community who have "forked" NerdDinner and done interesting stuff with it. Each of these samples is usually focused on a specific scenario, so they won't necessarily be merged with the trunk, but they are educational nonetheless. Jon Galloway and I have also added a few things to NerdDinner, taking it in a more social direction, as Jon's MVC Music Store today is a better "getting started"...(read more)

Creating an OData API for StackOverflow including XML and JSON in 30 minutes

March 28, 2010

I emailed Jeff Atwood last night a one line email. "You should make a StackOverflow API using OData." Then I realized that, as Linus says, Talk is Cheap, Show me the Code. So I created an initial prototype of a StackOverflow API using OData on an Airplane. I allocated the whole 12 hour flight. Unfortunately it took 30 minutes so I watched movies the rest of the time. You can follow along and do this yourself if you like. Preparation Before I left for my flight, I downloaded two things. First, I got Sam Saffron's "So Slow" StackOverflow SQL Server Importer . This is a little spike of Sam's that takes the 3gigs of XML Dump Files from StackOverflow's monthly dump and imports it into SQL Server. If you care, that...(read more)

The Weekly Source Code 51 – Asynchronous Database Access and LINQ to SQL Fun

March 2, 2010

You can learn a lot by reading other people's source code. That's the idea behind this series, " The Weekly Source Code ." You can certainly become a better programmer by writing code but I think good writers become better by reading as much as they can. I was poking around in the WebFormsMVP project's code and noticed an interesting pattern . You've seen code to get data from a database and retrieve it as an object, like this: public Widget Find(int id) { Widget widget = null; widget = (from w in _db.Widgets where w.Id == id select w).SingleOrDefault(); return widget; } This code is synchronous, meaning basically that it'll happen on the same thread and we'll wait around until it's finished. Now, here's...(read more)

The Weekly Source Code 50 – A little on “A generic error occurred in GDI+” and trouble generating images on with ASP.NET

February 18, 2010

I got a nice little Yellow Screen of Death (YSOD) error on some code running under IIS that worked fine when running on the VS Developer Web Server. The error was "A generic error occurred in GDI+" and you know that if an error is generic, it's sure in the heck not specific. My little application takes an overhead map that's stored in a local file, does some calculations from user input and draws an X on the map, then returns the resulting dynamically generated image. There's basically three ways to do images on the server side. Use Native APIs and Interop, which only works in full trust, use System.Drawing, which " isn't supported " or use WPF on the server side, which also, ahem, isn't officially supported...(read more)

SmallestDotNet Update – Now with .NET 4 support and an includable JavaScript API

February 9, 2010

A few years back I wrote a post on the size of the .NET Framework . There's historically been a lot of confusion on the site of the .NET Framework. If you search around on the web for ".NET Framework" or ".NET Framework Redistributable" you'll often get a link to a 200 meg download. That download is the complete offline thing that developers redistribute when they want to install the .NET Framework on any kind of machine without an internet connection. The .NET 3.5 Client Profile is more like 28 megs and the .NET 4 Client Profile is a looking smaller that than, in fact. Back then I made this website, SmallestDotNet.com to help out. It'll sniff your browser's UserAgent and tell you want version of .NET you...(read more)

The Weekly Source Code 48 – DynamicQueryable makes custom LINQ expressions easier

January 27, 2010

NOTE: An alternative title to this post might be: " The Weekly Source Code 48: Making The Weekly Source Code 47 Suck Incrementally Less. " Last week I wrote a post about Dynamic Linq Query Generation in order to solve a kind of meta-programming problem. I had a site that used ASP.NET Dynamic Data and I wanted to do a LINQ query against some data. However, because I was creating a template that didn't know enough at compile time to write a proper LINQ query that could, well, compile, I needed to creating my LINQ dynamically. Be sure to hang in here with me, the awesome happens at the end. I was trying to generate effectively this at runtime Items.Select(row => row.Property).Distinct.OrderBy(colvalue => colvalue) And I succeeded...(read more)