19 responses

  1. Paul Stevenson
    April 26, 2012

    fyi: The folk who control the network on which I work don’t allow the use of Northwind database. (It’s a STIG finding. http://en.wikipedia.org/wiki/Security_Technical_Implementation_Guide) Not your problem, of course, but I appreciate your articles. Just wish you didn’t use Northwind. Take care, Paul

  2. john
    August 25, 2011

    If you are doing any tutorial for newbies (as this was) then you need to appreciate the audience’s level and for such a small demonstration such as this I think it’s very poor. The URL to the database was not direct link. You should have checked that the NW database was IDENTICAL to yours. you should even have explained how to turn on line numbering and the format of the numbers.

    For future demonstrations may I suggest it would be better to use the new AdventureWorks database so that we all are, so-to=speak singing from the same hymn book.

  3. Fred Morrison
    July 20, 2011

    As long as you’re taking flack about Northwind, let’s really mix things up with an equivalent Lambda expression (Language = C# Statements, make sure you click the “Use Northwind” hyperlink in the upper-right corner):

    DataContext dataContext = this;
    .Where (Customers => (Customers.City == “London”))
    .Select (
    Customers =>
    CustomerID = Customers.CustomerID,
    CompanyName = Customers.CompanyName,
    ContactName = Customers.ContactName
    .Dump(“London Customers”)

    And you thought LINQPad was only for LINQ. Shame on you :-)

    • Fred Morrison
      July 20, 2011

      The GetTable got mangled during copy/paste of my example above. The GetTable should have been preceded by Customers in angled brackets. I suspect other people posting replies are a victim of WordPress’es lack of good copy/paste behavior.

    • Seven
      August 20, 2011

      If you’re looking to buy these atcirles make it way easier.

  4. Steve Hall
    July 20, 2011

    Ok, it seems YOUR Northwind has a Contacts table (well, SOMETIMES…) instead of a Customers table. I refactored the first query to:

    DataContext dataContext=this;
    var query=from Customers in dataContext.GetTable()
    where Customers.City==”London”
    select new {Customers.CustomerID,Customers.CompanyName,Customers.ContactName};

    and all is well…

    Lesson: All Northwind db’s weren’t created equally.

    Curiously, your examples starting at the “Map the table to an Entity Class” section switch over to using the Customers table… Inquiring minds want to know if this is a case for the Fringe Division (were there two Jesse’s writing this article?)

  5. Steve Hall
    July 20, 2011

    I ran into the same error as newbie above…which indicates that the Northwind db I downloaded from:


    doesn’t contain a Contacts table (as easily seen in the LINQPad connection treeview and within SSMS).

    I’ve also checked with the CodePlex project at:


    thinking that there might be a different Northwind db there. No such luck! The zipped copy there is the same as on the 23654 page. Nor could I find any other copy of it at any other obvious looking CodePlex project…

    Thus, the primary question is: Where’d you get your Northwind db? (Can you give us a better URL than http://msdn.microsoft.com/en-us/library/ms227484%28v=vs.80%29.aspx ? That URL is an Alice-In-Wonderland rabbit hole…)

    Of course, the secondary question is: Why aren’t you using AdventureWorks, since Northwind is deprecated (as noted on the 23654 page)? (No one should be using Northwind these days…)

    • Jesse Liberty
      July 20, 2011

      I didn’t realize i was using an older (or odd) copy of Northwind. In any case, the lessons here transcribe pretty easily to any mdf file. If you think it is truly confusing, I’m happy to write out the corresponding steps with AdventureWorks.

      • Steve Hall
        July 20, 2011

        No, that’s ok. I got the gist of it. But you might change the first two queries to use Customers instead…

        Overall, your tutorials are pretty good. Thanks!

  6. newbie
    July 20, 2011

    Newbie here. Selected “C# Statement”. Copied an pasted the first query into the Query 1 window of LINQPad and got the following error:

    The type or namespace name ‘Contacts’ could not be found (press F4 to add a using directive or assembly reference)

    • newbie
      July 21, 2011

      Used Customers instead of Contacts and it worked ok. I have the version of LINQPad with Intellisense so was able to play around nicely.

      Thanks for the article.

  7. Fred Morrison
    July 19, 2011

    Please clarify your post so that newbies will know what to set the all-important “Language:” dropdown box in LINQPad to. They may become confused unless you are crystal clear about whether your examples rely upon a “Language” setting of C# Expression, C# Statements, C# Program, or something else. I know I may seem picky, but even those of us who are fairly familiar with LINQPad (2.x or 4.x) will apreciate the clarfication rather than relying upon the vague “leave the other settings as-is…”.

    • Jesse Liberty
      July 19, 2011

      Very good point, and I should have done so. For the examples in this posting you’ll want to set the language to C# Statements.

      • Edaward
        December 10, 2012

        I have no trouble biindng a TextBlock to a property in a ViewModel and having it show up at design time. In fact, the ViewModel base class has a property called IsInDesignMode that you can use to return data that will only show up at design time.The way the InjectedViewModelLocator works is that it uses MEF to supply a service agent, either Real or Mock, to a ViewModel. MEF does not play nicely when used in design mode, so I have code in the locator that ensures MEF is only called at runtime and not design time.You can specify an agent type of Real or Mock in an attribute you place on the service agent. This acts as metadata for MEF so that the locator can decide to create either a real or a mock service agent. For example, if you look at the definition of MockItemListServiceAgent, you’ll see the ServiceAgentExport attribute with the AgentType set to Mock.Cheers,Tony

  8. Stuart Hemming
    July 19, 2011

    LinqPad is an essential tool for me now. I have found it quicker and easier, for the most part, to use it to do quick, ad hoc, queries of the DB than firing up MSSQL and writing a SQL query.

    Honestly, Joseph’s kit is well worth investigating and I bought a copy that has intellisense enabled too.

    Stop reading this and go download it!

    • Fred Morrison
      July 19, 2011

      Dittos on the worthiness of the extra-cost IntelliSense add-on to LINQPad.

    • Fred Morrison
      July 19, 2011

      More dittos on using LINQPad for quick, ad hoc queries, like this one against the Microsoft Enterprise Library Logging database for displaying only the most recent entries:
      // view most recent Enterprise Library log entries
      from l in Logs
      where l.Timestamp > DateTime.UtcNow.AddHours(-1)
      orderby l.LogID descending
      select new
      , l.Timestamp
      , l.Priority
      , l.Severity
      , l.Title
      , l.Message

Leave a Reply




Back to top
mobile desktop