LINQ

There are 3 entries for the tag LINQ

Error Handling in ASP.NET MVC 1 [Part 2 of 2]

In the first post in this series, I provided a little info on the HandleError attribute in MVC 1. In case you don’t want to flip back, the HandleError attribute can decorate a method or a class and will push your users to a generic errors view provided customErrors is “On” or “RemoteOnly”. There’s a little more to it, but that’s all the background we need for this post. The out-of-the-box HandleError attribute works well, until you’re in a scenario where you need to do more than hide your errors....
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Get the index of a given item using LINQ [quick-tip]

UPDATE: Please see first comment to do this the "safe" way... It took a bit for me to get comfortable enough with LINQ-to-objects to write ‘queries’ off the top of my head…but once you’re used to it you realize it’s much more concise, easier to interpret/read, and well..it’s less code. Here are some real quick examples… This first example selects the string array value as well as its position from the someItems array. Note, the user of new{} creates a new generic type that has the properties ItemName...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Returning values from your LINQ queries [quick tip]

Just a quick tip that I found handy while doing some writing yesterday; chances are if you’ve played with LINQ you probably wrote something like this… var outputString = from s in inputString where s.Length > 1 select s; //Do some stuff with outputString in your method... Code like the above will work perfectly well if what you’re going to work with your implicit variable, outputString, within the body of the same method. But, as it stands, you can’t return outputString, or any implicit variable...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Twitter