Thursday, March 12, 2009

LINQ passing query results

Wow, first off, I need a better way to post code to the blog. I noticed this guy has rigged up a way and I will give it a try when I have some time: Please make a note blog
In the meantime I put my code snippet as a crappy image. The problem that I had being a fairly new Linq user was, what if I want to pass the results of a LINQ query to another method, or based on some logic in an if statement, do something different for the query, how can I declare it so I can pass it or use it and assign it based on logic. I found that in the case where I know what I am getting back from my query, then I can declare an Ienumerable of my type and assign it or pass it as I please. In this case I had a query return squares in a sudoku puzzle. You can see below how to declare and then assign the results of one of two linq queries.

No comments:

Post a Comment