Join support

6 posts, 0 answers
  1. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 18 Jun 2009 Link to this post

    Please include LINQ join support for querying multiple objects. For example. This is HUGE for us.

    pseudo
    var result = from n in IScope.extent<customer>()
    JOIN o in IScope.extent<office>() 
    where c.officeId = o.id
    Thanks!


  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 19 Jun 2009 Link to this post

    Hi JDT,

    normally you should be able to just follow the reference on the Customer instance (the rev-engineering wizard should have created such a reference from Customer to Office). By following this reference, OpenAccess generated the needed joins internally. You can simply perform a linq query for the customer

    var res = from c in scope.Extent<Customer> select c


    Best wishes,
    Thomas
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Phil
    Phil avatar
    6 posts
    Member since:
    Jun 2007

    Posted 20 Jun 2009 Link to this post

    I second the request that JOINs are required.  As far as I can tell, OpenAccess will only generate the right joins if your database uses Foreign Keys to enforce Reference Integrity.  Ours, instead (for various reasons), uses triggers to enforce RI and so the relationships between tables isn't know to OA. 
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 22 Jun 2009 Link to this post

    Hello Phil,

    You can manually define the necessary relations using the Reverse mapping wizard. For the example you provided the steps would be as follows:
    • Open the Advanced View tab in the Reverse mapping wizard;
    • Select the class Customer from the treeview;
    • Click the Create Ref button;
    • Set an appropriate name for the reference (like Office) and choose the Office class from the Type combobox;
    • The first column (Field) in the grid below should now have a value (Office.id). Click on the blank field in the second column and from the combobox select the officeId field.
    • Save the configuration and generate the classes;
    Now you should be able to access the Office object directly from the Customer using the Customer.Office reference. Hope that helps.
    Greetings,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 22 Jun 2009 Link to this post

    That works, but what if we want to be able to build and run those queries on the fly? In our case we would have to go create a ton of references which is a pretty big project. Like Phil our relationships aren't set as FK, or enforced by the schema.

    Thanks.
  7. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 25 Jun 2009 Link to this post

    Hello JDT,

    I am afraid this is not possible at the moment. Theoretically you should be able to execute SQL statements with JOINs using the ObjectScope.GetSqlQuery() method, but the result would be an object array which is not very easy and type-safe to work with. However, the Linq support for Joins is scheduled for the Q3 release this year.

    All the best,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner