Instead of this:
var author = (from a in dataContext.Authors where a.Id == authorId select a).Single();
...use this:
var author = dataContext.Authors.Single(a => a.Id == authorId);
Also consider whether you wanted SingleOrDefault.
Instead of this:
var author = (from a in dataContext.Authors where a.Id == authorId select a).Single();
...use this:
var author = dataContext.Authors.Single(a => a.Id == authorId);
Also consider whether you wanted SingleOrDefault.
Marc Gravell wrote about using Expression<T> as a compiler. It was a bit of an eye-opener.
There's a bit in it where he says:
A similar approach [to using Expression for shallow cloning an object] might be used, for example, to map data between DTO entities and entity objects...
Say no more:
For some reason, LINQ's ForEach extension method doesn't work on IEnumerable<T>; it only works on IList<T>. Easy fix:
public static class EnumerableExtensions
{
public static void ForEach<T>(this IEnumerable<T> values, Action<T> action)
{
foreach (var value in values)
{
action(value);
}
}
} This seems to be causing a few problems, so I'll quickly walk through it. I'll try to throw some screenshots in later.
In the TestWizard project, choose "Add New Item". In the dialog, choose "Inherited User Control" (it's under Windows Forms). Call it OptionalPage.cs. The Inheritance Picker will appear. Choose "InternalWizardPage".
In the forms designer, click on the banner and change the Title and Subtitle properties to "Optional Page" and "This page is optional".
In the constructor for TestWizardSheet, add a line to add the OptionalPage:
Because Visual Studio doesn’t look for references in the GAC:
This is by design.
I'm at DevWeek this week, and I went (among other things) to a couple of WCF presentations by Aaron Skonnard.
So, anyway, last night I put together a really simple WCF service. It looks like this:
class FibonacciSequence : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return (long)0;
yield return (long)1;
long prev = 0;
long curr = 1;
for (; ; )
{
long next = prev + curr;
if (next < 0) // It overflowed. Stop.
yield break;
yield return next;
prev = curr;
curr = next;
}
}
}
It's possible, through the magic of COM interop, to call C# code from JScript or VBScript. Here's an example of how to do it from JScript.
If you try using IDictionary with the PropertyGrid control, the results aren't spectacular:

Here's how to do it properly.
In this installment (see here for the previous installment), we'll be fixing a few things and making the whole thing prettier.