This is a migrated thread and some comments may be shown as answers.

Join support

5 Answers 94 Views
Feature Requests
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
JDT
Top achievements
Rank 1
JDT asked on 19 Jun 2009, 03:37 AM
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!


5 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 19 Jun 2009, 04:53 PM
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.
0
Phil
Top achievements
Rank 1
answered on 20 Jun 2009, 07:44 PM
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. 
0
Alexander
Telerik team
answered on 22 Jun 2009, 09:02 AM
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.
0
JDT
Top achievements
Rank 1
answered on 22 Jun 2009, 09:48 PM
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.
0
Alexander
Telerik team
answered on 25 Jun 2009, 05:21 AM
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.
Tags
Feature Requests
Asked by
JDT
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Phil
Top achievements
Rank 1
Alexander
Telerik team
JDT
Top achievements
Rank 1
Share this question
or