Log et al – Peter Curd

An irreverent peek into the inner rumblings of Peter Curd

Oct

20

How to perform an SQL “IN” query in Linq

By pcurd

Using Linq to achieve a query that in SQL that uses the “IN” keyword – i.e. to check a value against a range of values – requires use of the .Contains method on a new array of the range of values.

For example, if I need to exclude from reports the following customers:

  1. Internal
  2. Demo
  3. Sample
I would in SQL use something like:
CustomerName NOT IN ('Internal', 'Demo', 'Sample')
In Linq I need something like:
!(new[] {"Internal", "Demo", "Sample"}).Contains(CustomerName))

Appropriately wired into EF or your ORM of choice.

I think this is confusing since it is written backwards to a SQL programmer, so it reads “does this list of things contain the value?” instead of “is the value in this list of things?” as we are used to in SQL.

Jan

1

Twitter Weekly Updates for 2012-01-01

By pcurd

  • Not impressed with Christmas Doctor Who, rubbish story full of "what? Why did they do that?". Makes me less likely to watch the last season. #
  • For those non Commonwealth citizens reading this: yes, Boxing Day is when the British gave gifts – to our servants. Now it's just a day off! #
  • Happy New Year all! #

Powered by Twitter Tools

Dec

25

Twitter Weekly Updates for 2011-12-25

By pcurd

  • Merry Christmas all! And to all, a good night! #

Powered by Twitter Tools

Dec

18

Twitter Weekly Updates for 2011-12-18

By pcurd

  • You know you're not going to enjoy a system change when the spec gives you a paper cut. #ouch #

Powered by Twitter Tools

Dec

4

Twitter Weekly Updates for 2011-12-04

By pcurd

  • I just got interviewed for the Reading 107 breakfast show tomorrow. Listen in for my opinions on Christmas Lights on houses! :-D #

Powered by Twitter Tools

Nov

13

Twitter Weekly Updates for 2011-11-13

By pcurd

  • I've just formally accepted a promotion to deputy manager of IT Administration – I am now allowed to wear patterned socks to work. #Whoop #

Powered by Twitter Tools

Oct

30

Twitter Weekly Updates for 2011-10-30

By pcurd

  • I NEED MORE BULLETS! I only scored 4874 in Wonton 51 #Wonton51 #
  • On route to #londonexpo – apparently people are there already! And I thought I'd be early! #
  • Entry to #londonexpo in N6! Those with tickets as well as ticket sales. In the queue now! @MCMExpo @londonexpo #
  • .@QCPGameworks save some stickers for me! #londonexpo #
  • Past security at #londonexpo now waiting for a wristband I think… Seems to be three layers of queuing – terribly British. I love it. #
  • I have a wristband and a goodie bag! #londonexpo #
  • MCM Expo – London Comic Con (@ ExCeL London w/ 14 others) [pic]: http://t.co/tM0m0gmI #

Powered by Twitter Tools

Oct

9

Twitter Weekly Updates for 2011-10-09

By pcurd

  • Read two chapters of #CSharpInDepth by @jonskeet, cut 16 pages of #EF generated SQL to 1 page. Thanks Jon! #AverageDay #
  • Loosing a visionary who changed everything from the way we talk to each other to how we define successful is tragic. We'll miss #SteveJobs #

Powered by Twitter Tools

Sep

18

Twitter Weekly Updates for 2011-09-18

By pcurd

  • Rumours of my untimely demise are greatly exaggerated. But yes, I do think @NaturalCon pushed me. I don't care if she was in front. :) #OW #
  • Royal County of Berkshire Show calls today, running a bit late as my sleep and stomach emptiness disagreed with my alarm clock. #

Powered by Twitter Tools

Sep

11

Twitter Weekly Updates for 2011-09-11

By pcurd

  • RT @Plip: If you work for a charity and need some free tech help I have two days left this year to donate. Anyone want them? @phil_crabtree #
  • Can anyone recommend a decent command line SFTP client for Windows? #Lazyweb #

Powered by Twitter Tools