So even though I usually like to think of myself as someone that is “in the know” of the latest and greatest technologies, lately I’ve been too busy to experiment with newer stuff. So about a month ago I decided to embark on a LINQ learning path, trying to learn as much about it as I can on my spare time (the small amount that I have), and also a project came up where I can make use of these new skills of mine. I’ve worked with data my entire career, even for my Senior Design project in college, I was the guy in charge of the data (schema, retrieval, updating it, etc), I like data and feel very comfortable dealing with it. LINQ is such a huge change for all developers, it allows us do so much more than we could’ve ever done before with it. And I’m not just talking about what you can do with LINQ to SQL or LINQ to XML, I’m talking about the plain vanilla LINQ. WOW!! There so much power and potential and it will take us to places that many people hadn’t thought of before.

So anyway I’ll update some of the cool things that I find in my LINQ venture. Here’s one…it took me a while to figure this out the other day. I needed to be able to do an “IN” clause using LINQ, something that in SQL would go like this:
WHERE myColumn IN (‘value1’, ‘value2’, ‘value3’)

This is how you do it in LINQ:

using (DataContext _DB = new DataContext(SqlConnection))
 string[] criteria = new string[] { "test", "test2", "test3" };
     var values = (from m in _DB.myTable
          where criteria.Contains(m.myColumn)
          select m);

It feels a bit weird at first, but then when you think about it, you have to think backwards in LINQ. So you are checking whether the values in the database are contained by your string array, rather than the other way around. Running profiler, you can see that the generated SQL is what was expected.

About esteban

Esteban is the Founder and Chief Technologist at Nebbia Technology, an ALM consulting and Azure-powered technology company. He is a software developer with a passion for ALM, TFS, Azure, and software development best practices. Esteban is a Microsoft Visual Studio ALM MVP and ALM Ranger, Pluralsight author, and the president of ONETUG (Orlando .NET User Group).

One thought on “Error when installing SQL 2008 on Windows Server 2008 R2 (64 bit)

  1. Mark Allen

    Another approach which works well is to have the XML tag reference a custom TFS group. In my case there is a master contributor group shared between projects so rather than list all the contributor users in the template AssignedTo list boxes I created a TFS group called ‘TeamAssignments’ and within security I referenced the team. Then in the templates I added the tag ListItem value=[project]\TeamAssignments. Now when anyone is added to the team they are displayed in the AssignedTo List box. This also means that another team can be created without changing the templates as the changes can be done in security.

    TFS Team Name: Blue (example set up in security)
    TFS Group Name: TeamAssignments
    Members: Team Blue

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? *