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

Datasource ?

3 Answers 99 Views
OQL (OQL specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hessner
Top achievements
Rank 2
Hessner asked on 03 Feb 2009, 11:45 PM
IQuery q = os.GetOqlQuery("SELECT ue.UserID, ue.Email, ue.FuldeNavn, ure.Medlemsnummer, re.RoleName FROM UserRoleExtent AS ure, UserExtent AS ue, RoleExtent AS re where ure.PortalID = 1 AND ure.UserID = ue.UserID AND ure.RoleID = re.RoleID");  
 
IQueryResult qr = q.Execute();  
RadGrid1.DataSource = ? 

"Playing" around with OQL, and found that:

1. No inner join possible in OQL?
2. No IListSource or IEnumerable or IDataSource return to feed RadGrid1.Datasource?

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 04 Feb 2009, 02:12 PM
Hello Bo Hessner Larsen,

Inner joins are completely possible with OQL but its syntax is a little bit different from SQL's. Because we deal with objects (not tables), we can use directly the references from one object to another. Your class model is not available to me so I wrote an example that uses the Northwind model:

SELECT c.CustomerID, o.OrderID, od.ProductID FROM CustomerExtent as c, c.Orders as o, o.OrderDetails as od WHERE o.OrderID == 10285 

Nevertheless this query returns a collection that is not very appropriate for binding an UI element to.

In this case I suggest you to use a Linq statement. The corresponding Linq statement to the example above is the following:
IQueryable result = from x in scope.Extent<OrderDetail>() 
                 where x.Order.OrderID == 10285 
 select new { x.ProductID,  x.Order.Customer.CustomerID, x.Order.OrderID }; 

The returned result from this Linq query is ready for binding. Hope this helps.

All the best,
Alexander
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hessner
Top achievements
Rank 2
answered on 04 Feb 2009, 02:46 PM
Hi Alexander,

I am not able to see/read your code sample - only the scroll bar are visible.

Ups, got in my e-mail, here it is:

SELECT c.CustomerID, o.OrderID, od.ProductID FROM CustomerExtent as c, c.Orders as o, o.OrderDetails as od WHERE o.OrderID == 10285   
 
.  
.  
 
 

Thanks for the LINQ tip.
0
Alexander
Telerik team
answered on 04 Feb 2009, 05:07 PM
Hi Hessner,

Sorry about that, it seems to be a bug with IE, will be fixed ASAP.

Now, about the code. Here it is the first snippet:

SELECT c.CustomerID, o.OrderID, od.ProductID
FROM CustomerExtent as c, c.Orders as o, o.OrderDetails as od
WHERE o.OrderID == 10285


And the second:

IQueryable result = from x in scope.Extent<OrderDetail>()
                                   where x.Order.OrderID == 10285
                                   select new { x.ProductID,  x.Order.Customer.CustomerID, x.Order.OrderID };


Best wishes,
Alexander
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
OQL (OQL specific questions)
Asked by
Hessner
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Hessner
Top achievements
Rank 2
Share this question
or