The EntitySpaces Community

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

Automatic LoadBy for unique fields

Last post 03-21-2008, 9:58 AM by dguaraglia. 6 replies.
Sort Posts: Previous Next
  •  03-20-2008, 6:07 AM 8481

    Automatic LoadBy for unique fields

    ADO.NET auto-generated datasets have a nice feature I'd like to see added to EntitySpaces: they generate both LoadBy and FindBy methods for unique fields. This could be implemented in ES to look like:

    Given a students table that has Id, ReferenceNumber and a bunch of other data, where Id is the primary key and ReferenceNumber is unique:

     

    Code:
    Dim student as New DataModels.Students
    student.LoadByReferenceNumber(refNo)
    

    Cheers,

    David

  •  03-20-2008, 6:19 AM 8483 in reply to 8481

    Re: Automatic LoadBy for unique fields

    That's a pretty good idea, yes, this is something we could do. We will add it our Trac system. It probably wont make this years first release of ES2008 but hopefully the fall release.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-20-2008, 10:35 AM 8494 in reply to 8483

    Re: Automatic LoadBy for unique fields

    Great! In particular I use FindByX in DataTables every so often. Having that in entity collections will be great!

    Thanks!

    David

     

     

  •  03-20-2008, 1:29 PM 8500 in reply to 8494

    Re: Automatic LoadBy for unique fields

    Just a note we do have a FindByPrimaryKey on the collection. I realize you may be asking to do this on any arbitrary column, but I just thought I'd add that its already there for your primary key column.
    .
    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  03-20-2008, 5:43 PM 8506 in reply to 8500

    Re: Automatic LoadBy for unique fields

    Hello,

    What mister is asking for (FindByx) could be nicely extended to an ES filter as described in this post ... some kind of filter based on the same syntax than the neat esQuery syntax. Imagine having to filter on a date column on an sqlserver/access/vistadb/db2 based esCollection etc... some times you have to wrap your dates in #date# sometimes in 'date'. So if entity spaces could handle this for us, our code would be even less provider dependant... just a thought
     


    Thanks!

    - El pipo -
  •  03-21-2008, 9:36 AM 8511 in reply to 8506

    Re: Automatic LoadBy for unique fields

    I understand how a DynamicQuery-like syntax for collection.Filter would be very useful. The more hard-coded strings you can eliminate, and the more errors that are caught at compile-time rather than run-time, the better. The enhancement request is in our tracking system, but the implementation is not a simple one, as Mike pointed out in the linked post.

    However, I think you are confusing database-specific SQL syntax with the .NET DataColumn.Expression syntax. Whether you wrap SQL Server date literals in single quotes, or MS Access date literals in pound signs, is un-related to Filter expressions. Expression literals are dependent on the column's .NET datatype. For DateTime columns, literals are always wrapped in pound signs, i.e., #date#. String columns are wrapped in single quotes, i.e., 'string'.

    If, in a particular filtering instance, you need to do this - 'date', it is because the column that contains the date representation is defined as a string column, not because it originated from SQL Server. EntitySpaces collections contain DataTables of Columns with .NET System.DataTypes that have been converted from db-specific types by the EntitySpaces providers. Any Filter expressions applied to them are already provider independent.


    David Neal Parsons
    www.entityspaces.net
  •  03-21-2008, 9:58 AM 8512 in reply to 8511

    Re: Automatic LoadBy for unique fields

    True! Actually, after playing for a while with the filters I realized I was mistaken, and was going to edit the post, but you had already answered :)

     

    Anyway, it will probably help eliminate the need to format the string myself, as you point out. It also allows the user to use intelli-sense to autocomplete the fields. I'll try to check how much work would be to do that, and if I can come with some implementation, or beginning of one, I'd gladly contribute that to the library.

     

    Cheers,

    David

View as RSS news feed in XML