The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Query.Load returns true

Last post 02-21-2008, 10:15 AM by Mike.Griffin. 3 replies.
Sort Posts: Previous Next
  •  02-21-2008, 9:03 AM 8160

    Query.Load returns true

    I am trying to do a simple lookup to see if a value exist before saving.  When I call the Load() method it returns true.  Also the next available primary key is returned so I am unable to find out if the record is actually there or not.  This seems like the approach but I am not getting the results as I expected.

    Code:
        Private Function GetTrayId(ByVal trayNmber As Integer) As Integer
            Dim sampleTray As New SampleTray()
            sampleTray.Query.Select(sampleTray.Query.SampleTrayId)
            sampleTray.Query.Where(sampleTray.Query.TrayNumber.Equal(trayNmber))
            If (sampleTray.Query.Load()) Then
                GetTrayId = sampleTray.SampleTrayId
            Else
                GetTrayId = AddSampleTray(trayNmber)
            End If
        End Function

    Thanks Team 

    John


    MullerSoft
  •  02-21-2008, 9:36 AM 8161 in reply to 8160

    Re: Query.Load returns true

    There is nothing wrong with the code. If Query.Load() is returning true then it found the record. Also, I would improve your query like this:

    OLD: sampleTray.Query.Where(sampleTray.Query.TrayNumber.Equal(trayNmber))

    NEW: sampleTray.Query.Where(sampleTray.Query.TrayNumber == trayNmber) 

    We support all of the natural language operators and it makes your query much easier to read.

    Why aren't you using an Identity column for this? I'm not sure what the issue really is or why you say "you are not getting the results as you expected" ?

     

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  02-21-2008, 9:47 AM 8162 in reply to 8160

    Re: Query.Load returns true

    My Bad, after pounding my head for an hour and a half, I thought to look at the connection string and it was changed to a different database.  Now that it is pointing to the correct db, the results are as expected.  Sorry for the unnecessary post

     John


    MullerSoft
  •  02-21-2008, 10:15 AM 8163 in reply to 8162

    Re: Query.Load returns true

    No problem, glad you got it.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML