This is with 3.5SP1, and unfortunately it took me most of the day to figure out.
While it looks like LINQ-to-SQL (SqlMetal in this case, I assume) supports sprocs that return “raw” (unnamed) columns, naming them Column1 through ColumnN, at runtime they don’t actually get populated with the real data, leaving them always as default(T) for their type.
The easiest way to explain it is to show the repro cases:
Source of the (painfully simple) sprocs:
CREATE PROCEDURE GetRawColumns
CREATE PROCEDURE GetNamedColumns
SELECT 1 as a,2 as b,3 as c
C# calls to them once they’re added to the dbml (using the UI to drag-drop the sprocs from Server Explorer in this case)
var raw = db.GetRawColumns();
var rawList = raw.ToList();
var named = db.GetNamedColumns();
var namedList = named.ToList();
Actual runtime (in the debugger) values:
I haven’t tried mixing named and unnamed columns or anything like that – this blog post represents as much time as I’m willing to put into the bug now that I know a workaround :)