Why does this query work??

3 posts, 1 answers
  1. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 31 Jul 2009 Link to this post

    Hello everybody, I recognize this question might sound odd.
    I was trying get a set of products (ArticuloEmpresa) for a given company (EmpresaID) where there exists at least one order (Pedido) for each product.
    So, products are ArticuloEmpresaExtent and orders are PedidoExtent.
    I tryed this query and it works ok. But as I was just testing I would expect it to return all the "PedidoExtent" fields too as it was SQL.

    SELECT * FROM ArticuloEmpresaExtent AS x,
                                    PedidoExtent as y
    WHERE  x.EmpresaID = "640d6df6-994a-4173-9b31-473eb5b5d76f" AND
    y.Articulo = x AND
     y.Estado = "AceptadoEnvio"

    I was happy to see that only the "ArticuloEmpresaExtent" are retrieved, but I don't understand why.
    ¿Can anyone explain to me please?

    Best regards,

    Gonzalo
  2. Answer
    TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 03 Aug 2009 Link to this post

    Hi gmendez,

    OpenAccess (OA) is querying to get objects of a specific type.. In your case the first type you listed in the SELECT.

    If the "products" and "orders" are associated..example: In the Order class you have a list of <Product> instances. Then, you can select the Order instances and for each Order instance use the property "Products" to navigate the products...  like order.Products

    The result of an OQL query always is of a specific class type.

    Regards

    Henrik


  3. DevCraft banner
  4. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 05 Aug 2009 Link to this post

    Hello Henrik, very useful explanation.
    Thanks a lot.
    Best regards,

    Gonzalo
Back to Top