Simple OQL query - "extent" ???

6 posts, 0 answers
  1. MWM
    MWM avatar
    64 posts
    Member since:
    Jul 2007

    Posted 08 Dec 2008 Link to this post

    I am trying to perform a simple OQL query:

    string

     

    queryString = "select org from Org as org where org.id = \"1\"";

     

     


    IObjectScope
    scope = Database.Get("DatabaseConnection1").GetObjectScope();

     

     

    IQuery oqlQuery = scope.GetOqlQuery(queryString);

     

     

    IQueryResult result = oqlQuery.Execute();

     


    and I get this error:

    Invalid syntax: Did you mean '... FROM OrgExtent AS ...' ?


    In the online docs, I see the example of "EmployeeExtent".  What is this "extent" part?

    The name of my table is "Org".  I am trying to query a single record whose id equals 1.  Any example you can provide or correction to my code would be appreciated.
  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 09 Dec 2008 Link to this post

    Hello MWM,
    OQL is referencing class and fieldnames. ORG is your class name and in OQL the collection of all objects of that type is name OrgExtent.

    The query has to be:

    "select * from OrgExtent as org where org.id = \"1\"

    You should always use parameters instead of hard coded values because our query cache is working getter then.

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. MWM
    MWM avatar
    64 posts
    Member since:
    Jul 2007

    Posted 09 Dec 2008 Link to this post

    Hi Jan!  Thanks for getting back to me.

    I figure that Vanatec is responsible for this "Extent" thing, but man!  It's bizarre to say the least.

    I will give this a try.

    FYI - I just posted to:  http://www.telerik.com/community/forums/thread/b311D-btthdb.aspx and thought you might want to take a look.  Basically I'm seeing a lot of similarities in OA and an open-source ORM called NHibernate.  Both products seem to use a mapping file, a "factory" (singleton approach) for the life of the application and then a "scope" for each transaction (NH calls it a "session").  Thing is that NH provides "out-of-the-box" basic CRUD whereas I'm not seeing that for OA, at least for simple things like getting a single record based on a pk.  I could be entirely wrong though as I'm new to OA, for only a week or so now. 

    Thanks again for your assistance.

    Mark
  5. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 10 Dec 2008 Link to this post

    Hello MWM,
    Just to clarify this further you can take a look at our documentation regarding the Extents part of OQL:
    http://www.telerik.com/help/openaccess-orm/oql-the-select-statement-extents.html

    Hope this helps.

    Regards,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 02 Dec 2012 Link to this post

    hi Dimitar

    The link is broken.

    Regards Erik
  7. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 03 Dec 2012 Link to this post

    Hello Erik,

    Here you can find the new link for OQL Select query extents.

    Let us know if you find any other discrepancies.

    All the best,
    Ivailo
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top
DevCraft banner