Re: Criteria objects

From: VisionSet (spam_at_ntlworld.com)
Date: 08/24/04


Date: Tue, 24 Aug 2004 05:52:17 GMT


"Sudsy" <bitbucket44@hotmail.com> wrote in message
news:412AC575.8090507@hotmail.com...
> VisionSet wrote:
> <snip>
> > But I'm a little unhappy about this, a null primary key?
> >
> > Is this abuse of the object? should I have a separate criteria class?
> >
> > I'm after the simplest design that I do feel happy about.
>
> It's a perfectly valid approach (and one I've used). When you pass
> value-objects containing record data, using the same for search
> criteria makes sense. Ignore those fields which have been set to
> null and only search on the populated fields, even if they are
> empty Strings. So you're not actually searching for a null primary
> key in your example. You're indicating that you haven't specified
> the key and to not use it as part of the selection.
> I should mention that if the database generates the primary key
> automatically then setting it to null in the constructor is
> perfectly valid when creating a new record.
>

Thanks for the reply

When I use objects returned from the database I don't really want to have to
check for nulls in the fields.
But if I also use the class for criteria objects then I'm going to have to,
despite the fact I know my database won't return null fields my Record
documentation is going to say that null elements are valid.

-- 
Mike W


Relevant Pages

  • Re: problem using identity column as primary key
    ... >> I am thinking of creating an identity column to use it as primary key ... More and more programmers who have absolutely no database training are ... the gap in the sequence is not filled in and the sequence ... vin CHARNOT NULL REFERENCES Motorpool); ...
    (microsoft.public.sqlserver.programming)
  • Re: Record Lookup
    ... You need for that the command.executescalar, however VBNet is when you are a newbie not as simple as VBA. ... To get a field from a database you need: ... Number or First Name or Last Name or any criteria field I choose and return ... > primary key in the table to the field that I wanted to use for the> search ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Record Lookup
    ... Number or First Name or Last Name or any criteria field I choose and return ... The problem is that a novice can ask more difficult questions than somebody ... primary key in the table to the field that I wanted to use for the search ... a single Access database table and return the value of one field ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Record Lookup
    ... The problem is that a novice can ask more difficult questions than somebody who knows what he wants. ... primary key in the table to the field that I wanted to use for the search ... criteria and that didn't work. ... >>> a single Access database table and return the value of one field ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Updating the SQL key value
    ... before creating the database, by the time I've come to pick a primary key, ... articles, each of which must be issued under a particular licence (e.g. ... GPL GNU General Public Licence http://www.gnu ... ...
    (comp.lang.php)