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. Other Discussions
  3. The Weird and The Wonderful
  4. What this 'null' check doing here...

What this 'null' check doing here...

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpdotnetwcf
59 Posts 25 Posters 6 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.
  • V VallarasuS

    Guess he don't believe the guys at microsoft! :laugh:

    Regards Vallarasu S | BreakingDotNet.blogspot.com

    M Offline
    M Offline
    Mohammed Hameed
    wrote on last edited by
    #6

    Then, he must be a Genius ;P

    Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

    1 Reply Last reply
    0
    • P Pete OHanlon

      Is this inside a single method? I'd be more concerned here with the fact you'd never fill the employees list.

      I was brought up to respect my elders. I don't respect many people nowadays.
      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      M Offline
      M Offline
      Mohammed Hameed
      wrote on last edited by
      #7

      Quote:

      Is this inside a single method?

      Yes, it is.

      Quote:

      I'd be more concerned here with the fact you'd never fill the employees list.

      How??

      Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

      P B 2 Replies Last reply
      0
      • M Mohammed Hameed

        Quote:

        Is this inside a single method?

        Yes, it is.

        Quote:

        I'd be more concerned here with the fact you'd never fill the employees list.

        How??

        Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #8

        Never mind - I've been up for the last 16 hours. I was reading != as == here for some reason. :doh:

        I was brought up to respect my elders. I don't respect many people nowadays.
        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        M K 2 Replies Last reply
        0
        • P Pete OHanlon

          Never mind - I've been up for the last 16 hours. I was reading != as == here for some reason. :doh:

          I was brought up to respect my elders. I don't respect many people nowadays.
          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

          M Offline
          M Offline
          Mohammed Hameed
          wrote on last edited by
          #9

          Ohh, that's okay...

          Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

          1 Reply Last reply
          0
          • P peterchen

            Keeping the runtime on its toes.

            ORDER BY what user wants

            J Offline
            J Offline
            jim lahey
            wrote on last edited by
            #10

            I hope there's a unit test for that too.

            1 Reply Last reply
            0
            • M Mohammed Hameed

              List<Employee> employees = new List<Employee>();

              if (employees != null){
              employees = GetEmployees();
              }

              Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

              N Offline
              N Offline
              Nicholas Marty
              wrote on last edited by
              #11

              Hm. and why even initialize the variable if you're going to assign another value anyway?

              M 1 Reply Last reply
              0
              • M Mohammed Hameed

                List<Employee> employees = new List<Employee>();

                if (employees != null){
                employees = GetEmployees();
                }

                Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                T Offline
                T Offline
                Trajan McGill
                wrote on last edited by
                #12

                And what is the " = new List()" doing there, either? Assign it one value, then if it isn't null, which it can't be, immediately assign it another value and discard the first object? Goofy.

                M 1 Reply Last reply
                0
                • T Trajan McGill

                  And what is the " = new List()" doing there, either? Assign it one value, then if it isn't null, which it can't be, immediately assign it another value and discard the first object? Goofy.

                  M Offline
                  M Offline
                  Mohammed Hameed
                  wrote on last edited by
                  #13

                  Thanks for raising this point.

                  Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                  1 Reply Last reply
                  0
                  • N Nicholas Marty

                    Hm. and why even initialize the variable if you're going to assign another value anyway?

                    M Offline
                    M Offline
                    Mohammed Hameed
                    wrote on last edited by
                    #14

                    Thanks.

                    Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                    1 Reply Last reply
                    0
                    • M Mohammed Hameed

                      List<Employee> employees = new List<Employee>();

                      if (employees != null){
                      employees = GetEmployees();
                      }

                      Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                      B Offline
                      B Offline
                      Brisingr Aerowing
                      wrote on last edited by
                      #15

                      :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh:

                      T J 2 Replies Last reply
                      0
                      • B Brisingr Aerowing

                        :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh:

                        T Offline
                        T Offline
                        Thomas Daniels
                        wrote on last edited by
                        #16

                        Arrrggghhhh! My eyes! :eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::

                        Z 1 Reply Last reply
                        0
                        • M Mohammed Hameed

                          List<Employee> employees = new List<Employee>();

                          if (employees != null){
                          employees = GetEmployees();
                          }

                          Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                          V Offline
                          V Offline
                          vonb
                          wrote on last edited by
                          #17

                          Well, the null has really nothing to do there. Check if(employees.Count()==0) I would do like this

                          class TestClass()
                          {
                          List employees { get; set; }

                           TestClass()
                           {
                                employees = GetEmployees();
                           }
                          
                           private List GetEmployees()
                           {
                                return (from oRec in DataModel.Employees select oRec).ToList();
                           }
                          

                          }

                          The signature is in building process.. Please wait...

                          M Richard DeemingR 2 Replies Last reply
                          0
                          • V vonb

                            Well, the null has really nothing to do there. Check if(employees.Count()==0) I would do like this

                            class TestClass()
                            {
                            List employees { get; set; }

                             TestClass()
                             {
                                  employees = GetEmployees();
                             }
                            
                             private List GetEmployees()
                             {
                                  return (from oRec in DataModel.Employees select oRec).ToList();
                             }
                            

                            }

                            The signature is in building process.. Please wait...

                            M Offline
                            M Offline
                            Mohammed Hameed
                            wrote on last edited by
                            #18

                            Thanks.

                            Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                            1 Reply Last reply
                            0
                            • V vonb

                              Well, the null has really nothing to do there. Check if(employees.Count()==0) I would do like this

                              class TestClass()
                              {
                              List employees { get; set; }

                               TestClass()
                               {
                                    employees = GetEmployees();
                               }
                              
                               private List GetEmployees()
                               {
                                    return (from oRec in DataModel.Employees select oRec).ToList();
                               }
                              

                              }

                              The signature is in building process.. Please wait...

                              Richard DeemingR Offline
                              Richard DeemingR Offline
                              Richard Deeming
                              wrote on last edited by
                              #19

                              vonb wrote:

                              return (from oRec in DataModel.Employees select oRec).ToList();

                              Why do so many people insist on adding a pointless "from x in source select x" query to their code, when it has the same result as the much more concise "source"?

                              private List<Employee> GetEmployees()
                              {
                              return DataModel.Employees.ToList();
                              }


                              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                              V 1 Reply Last reply
                              0
                              • Richard DeemingR Richard Deeming

                                vonb wrote:

                                return (from oRec in DataModel.Employees select oRec).ToList();

                                Why do so many people insist on adding a pointless "from x in source select x" query to their code, when it has the same result as the much more concise "source"?

                                private List<Employee> GetEmployees()
                                {
                                return DataModel.Employees.ToList();
                                }


                                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                V Offline
                                V Offline
                                vonb
                                wrote on last edited by
                                #20

                                This was just a simple implementation of more complex queries which I actually use

                                publc List GetEmployees(int departmentId)
                                {
                                return (from oRec in DataModel.Employees where oRec.DepartmentID == departmentId).ToList();
                                }

                                The signature is in building process.. Please wait...

                                Richard DeemingR 1 Reply Last reply
                                0
                                • T Thomas Daniels

                                  Arrrggghhhh! My eyes! :eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::

                                  Z Offline
                                  Z Offline
                                  ZurdoDev
                                  wrote on last edited by
                                  #21

                                  Do you two realize how much money you just cost CP with this waste of disk space? You better click on some ads to pay for your mistakes.

                                  There are only 10 types of people in the world, those who understand binary and those who don't.

                                  M 1 Reply Last reply
                                  0
                                  • V vonb

                                    This was just a simple implementation of more complex queries which I actually use

                                    publc List GetEmployees(int departmentId)
                                    {
                                    return (from oRec in DataModel.Employees where oRec.DepartmentID == departmentId).ToList();
                                    }

                                    The signature is in building process.. Please wait...

                                    Richard DeemingR Offline
                                    Richard DeemingR Offline
                                    Richard Deeming
                                    wrote on last edited by
                                    #22

                                    That's one of the reasons why I tend to prefer the method-call syntax for most LINQ queries - if you remove the .Where(filter) clause, your code still looks sensible.

                                    return DataModel.Employees.Where(oRec => oRec.DepartmentID == departmentId).ToList();


                                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                                    1 Reply Last reply
                                    0
                                    • B Brisingr Aerowing

                                      :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh: :doh:

                                      J Offline
                                      J Offline
                                      Johnny YYZ
                                      wrote on last edited by
                                      #23

                                      You owe me for the bandwidth cost of 2396 unnecessary :doh:s! Only the icon has 831 bytes, which amounts to a total of 1,991,076 wasted bytes. Gotta count now the extra html chars and send you the invoice! :doh: :sigh: :laugh:

                                      1 Reply Last reply
                                      0
                                      • M Mohammed Hameed

                                        List<Employee> employees = new List<Employee>();

                                        if (employees != null){
                                        employees = GetEmployees();
                                        }

                                        Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                                        D Offline
                                        D Offline
                                        David C Thompson
                                        wrote on last edited by
                                        #24

                                        Probably code that has been edited and then not refactored. No real wtf here, ey?

                                        M 1 Reply Last reply
                                        0
                                        • M Mohammed Hameed

                                          Quote:

                                          Is this inside a single method?

                                          Yes, it is.

                                          Quote:

                                          I'd be more concerned here with the fact you'd never fill the employees list.

                                          How??

                                          Previous -> Read "CLR via C#" by Jeffrey Ritcher. Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder. Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.

                                          B Offline
                                          B Offline
                                          bencr
                                          wrote on last edited by
                                          #25

                                          It isn't really filling the list, it's replacing the reference with the result of that method call. I don't think that's what he meant though. A bit pedantic, I'm sorry.

                                          K 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