Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. My girlfriend asked why I always cursed at LINQ

My girlfriend asked why I always cursed at LINQ

Scheduled Pinned Locked Moved The Lounge
databasecsharplinq
23 Posts 14 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MadMyche
    wrote on last edited by
    #1

    So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

    OriginalGriffO M F M P 12 Replies Last reply
    0
    • M MadMyche

      So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      I know what you mean, I prefer to use the Linq methods as well - the Linq syntax is just a PITA to read.

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      N 1 Reply Last reply
      0
      • M MadMyche

        So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

        M Offline
        M Offline
        MadMyche
        wrote on last edited by
        #3

        Please forgive my lack of markdownability....

        1 Reply Last reply
        0
        • M MadMyche

          So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

          F Offline
          F Offline
          F ES Sitecore
          wrote on last edited by
          #4

          My girlfriend asked me why I cursed at LINQ and I told her to get in the kitchen and make me a sandwich.

          M 1 Reply Last reply
          0
          • F F ES Sitecore

            My girlfriend asked me why I cursed at LINQ and I told her to get in the kitchen and make me a sandwich.

            M Offline
            M Offline
            MadMyche
            wrote on last edited by
            #5

            But she had to do the shopping first so she could make the sandwich... I didn't dare want to make her do ``UNION``'s with the bakery and the cheese factory

            1 Reply Last reply
            0
            • M MadMyche

              So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

              M Offline
              M Offline
              Member 9024102
              wrote on last edited by
              #6

              var query = Grocery.Store
              .Where(item => item.Price < 1.99 && item.Fresh == true && item.Type.Contains("Produce"))
              .Take(5)

              1 Reply Last reply
              0
              • M MadMyche

                So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                I do wish SQL would allow multiple WHEREs in place of ANDs -- just to assist with developing queries I'm working on in SSMS and I want to experiment with various WHERE clauses.

                M J 2 Replies Last reply
                0
                • P PIEBALDconsult

                  I do wish SQL would allow multiple WHEREs in place of ANDs -- just to assist with developing queries I'm working on in SSMS and I want to experiment with various WHERE clauses.

                  M Offline
                  M Offline
                  MadMyche
                  wrote on last edited by
                  #8

                  I can see it both ways, when I'm in SSMS and playing with WHERE options I end up with ```sql SELECT * FROM Table WHERE -- FirstName = 'Herman' -- AND LastName = 'Munster' ```

                  P 1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    I do wish SQL would allow multiple WHEREs in place of ANDs -- just to assist with developing queries I'm working on in SSMS and I want to experiment with various WHERE clauses.

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #9

                    And how would you handle ORs?

                    Wrong is evil and must be defeated. - Jeff Ello

                    J P 2 Replies Last reply
                    0
                    • J Jorgen Andersson

                      And how would you handle ORs?

                      Wrong is evil and must be defeated. - Jeff Ello

                      J Offline
                      J Offline
                      Jalapeno Bob
                      wrote on last edited by
                      #10

                      In the water, of course...(stroke! stroke! stroke!....) :)

                      __________________ Lord, grant me the serenity to accept that there are some things I just can’t keep up with, the determination to keep up with the things I must keep up with, and the wisdom to find a good RSS feed from someone who keeps up with what I’d like to, but just don’t have the damn bandwidth to handle right now. © 2009, Rex Hammock

                      1 Reply Last reply
                      0
                      • J Jorgen Andersson

                        And how would you handle ORs?

                        Wrong is evil and must be defeated. - Jeff Ello

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        I hardly ever need to. Sometimes a I need an IN, but rarely an OR. And I'm not saying remove AND and OR, just make any additional WHEREs act as ANDs.

                        J 1 Reply Last reply
                        0
                        • M MadMyche

                          I can see it both ways, when I'm in SSMS and playing with WHERE options I end up with ```sql SELECT * FROM Table WHERE -- FirstName = 'Herman' -- AND LastName = 'Munster' ```

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #12

                          Right, so sometimes I wind up making

                          SELECT * FROM Table
                          WHERE 1=1
                          -- AND FirstName = 'Herman'
                          AND LastName = 'Munster'

                          just so I have flexibility while I experiment.

                          1 Reply Last reply
                          0
                          • M MadMyche

                            So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

                            R Offline
                            R Offline
                            Ron Anders
                            wrote on last edited by
                            #13

                            Don't take them for granted. Making them read code and all.

                            1 Reply Last reply
                            0
                            • M MadMyche

                              So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #14

                              MadMyche wrote:

                              I think she understands now

                              or: (select bacon).take(all) ;P Marc

                              Latest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                              M 1 Reply Last reply
                              0
                              • M Marc Clifton

                                MadMyche wrote:

                                I think she understands now

                                or: (select bacon).take(all) ;P Marc

                                Latest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                M Offline
                                M Offline
                                MadMyche
                                wrote on last edited by
                                #15

                                I would throw an ``Flavor Overflow Exception at pound #10`` error

                                1 Reply Last reply
                                0
                                • M MadMyche

                                  So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

                                  S Offline
                                  S Offline
                                  Smart K8
                                  wrote on last edited by
                                  #16

                                  That's why it's called programming and not laymen language. ;P

                                  1 Reply Last reply
                                  0
                                  • M MadMyche

                                    So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #17

                                    Girlfriend 1, MadMyche 0 Get ready to pay up.

                                    Peter Wasser "The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell

                                    1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      I hardly ever need to. Sometimes a I need an IN, but rarely an OR. And I'm not saying remove AND and OR, just make any additional WHEREs act as ANDs.

                                      J Offline
                                      J Offline
                                      Jorgen Andersson
                                      wrote on last edited by
                                      #18

                                      When I'm testing out filters I'm usually starting with WHERE 1=1 and add all conditions with an AND. But I can see what you're getting at. <edit>Just as you answered to Madmyche</edit>

                                      Wrong is evil and must be defeated. - Jeff Ello

                                      1 Reply Last reply
                                      0
                                      • M MadMyche

                                        So I gave her a grocery list in LINQ ```cs var query_where1 = ( from item in Grocery.Store where item.Price < 1.99 where item.Fresh == true where item.Type.Contains("Produce") select item).Take(5); ``` Which she really didn't care for; and I followed up with it in SQL ```sql SELECT TOP 5 * FROM Grocery.Store WHERE Price < 1.99 AND Fresh = 1 AND Type = 'Produce' ``` I think she understands now

                                        D Offline
                                        D Offline
                                        David Crow
                                        wrote on last edited by
                                        #19

                                        Looks to me just a simple matter of different syntax. One does not appear to be any more succinct or easier to read than the other.

                                        "One man's wage rise is another man's price increase." - Harold Wilson

                                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                                        L 1 Reply Last reply
                                        0
                                        • OriginalGriffO OriginalGriff

                                          I know what you mean, I prefer to use the Linq methods as well - the Linq syntax is just a PITA to read.

                                          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                          N Offline
                                          N Offline
                                          Nish Nishant
                                          wrote on last edited by
                                          #20

                                          +1 :thumbsup:

                                          Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups