Datasource ?

4 posts, 1 answers
  1. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 03 Feb 2009 Link to this post

    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?

  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 04 Feb 2009 Link to this post

    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.
  3. DevCraft banner
  4. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 04 Feb 2009 Link to this post

    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.
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 04 Feb 2009 Link to this post

    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.
Back to Top