Silverlight Ria Services ORM Grid Hierarchy

8 posts, 0 answers
  1. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 14 Mar 2013 Link to this post

    I am looking to create a 3 level Hierarchy. I am Using RadDomainDataSource to load the data.

    My structure is such: Grid - Child Grid - Child Dataform

    I managed using RadGridView and RadGridView.HierarchyChildTemplate
    However this solution requires that each child needs its own RadDomainDataSource  within its template.This solution becomes quite complex.I have been shown an eg using rowsdetailstemplate. Is it possible  to use RadGridView.RowDetailsTemplate and ORM

    The solution given is much simpler and the code uses LinqtoEntities

    public IQueryable<Order> GetOrders()
            {
                return this.ObjectContext.Orders
                    .Include("Order_Details")
                    .Where(o => o.Order_Details.Count > 0)
                    .OrderBy(o => o.OrderID);
            }

    however the above code does not work with ORM and datacontext error

    does not contain a definition for 'Include' and the best extension method overload 'Telerik.OpenAccess.ExtensionMethods.Include<T>(System.Linq.IQueryable<T>, System.Linq.Expressions.Expression<System.Func<T,object>>)' has some invalid arguments    

    Can the include be used in ORM.

    mike




  2. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 19 Mar 2013 Link to this post

    Hi Mike,

    Generally, eager loading with Telerik OpenAccess ORM is performed using fetch plans and our FetchStrategy class. The fetch plans allow you to specify which navigation properties to be loaded along with the object that you query for. They can be defined either per query or per context.

    In this set of documentation articles you can find a variety of examples regarding the definition and the usage of fetch plans.

    I hope that helps. If you have other questions, do not hesitate to get back to us.


    Regards,
    Doroteya
    the Telerik team
    Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.
  3. DevCraft banner
  4. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 20 Mar 2013 Link to this post

    Hi, thanks for the link, I have been looking into this and find it too be exactly what I need. One question. How can this be called by the domain service. for example this code ( in partial class) can be called by GetOrders()
    public IQueryable<Order> GetOrders()
            {
                return this.ObjectContext.Orders
                    .Include("Order_Details")
                    .Where(o => o.Order_Details.Count > 0)
                    .OrderBy(o => o.OrderID);
            }

    how can I call this code in the same way as

    <telerik:RadDomainDataSource x:Name="ordersDomainDataSource"
                                         AutoLoad="True"
                                         QueryName="GetOrders">
     there is no name specified to this block of code??
    using (EntitiesModel dbContext = new EntitiesModel())
    {
       Telerik.OpenAccess.FetchOptimization.FetchStrategy fetchStrategy = new Telerik.OpenAccess.FetchOptimization.FetchStrategy();
       fetchStrategy.LoadWith<Car>(c => c.Category);
       fetchStrategy.LoadWith<Car>(c => c.RentalOrders);
     
       IQueryable<Car> cars = from car in dbContext.Cars.LoadWith(fetchStrategy)
                               select car;
     
       // Only one database query is performed.
       foreach (Car car in cars)
       {
           Console.WriteLine("Car=" + car.Model + " Category=" + car.Category.CategoryName +
               " Orders Count=" + car.RentalOrders.Count);
       }
    }

    How do I name the method? Im trying to use MVVM and not have to place in the codebehind of the page
    .
    also how do you consume the result back in the xaml. all examples use             "console.writeline...."
    I am looking to bring back the data with                                                                 "return this.<>"

    regards
    mike



  5. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 25 Mar 2013 Link to this post

    Hello Mike,

    As far as I understand the scenario you are trying to implement, you need to eagerly load a collection of entities and to attach the result as a data source to a control on your interface.

    If that is, indeed the case, I suggest you the following steps:
    1) Extend the service with a custom query method, which will hold the fetch strategy and the query itself.
    2) Create a repository for the the entity that you will query and in it place a method that calls the custom query method from the service
    3) In the viewmodel for you application, create a public method that will hold the retrieved collection and a method that calls the method from the repository. Attach the result of this method to the public property and use it in the binding clause in your xaml code.

    You can find details and code samples regarding this process in our Sofia Car Rental - WCF RIA Services examples, delivered to you with our Samples Kit. I suggest that you open the documentation about this sample (click on the name of the sample and select Open Documentation) and take a look at:
    - Exercise 1, Task 4: Adding Query Methods
    - Exercise 2, Task 3: Implementing Load, Create, Update, Delete Operations
    - Exercise 3, Task 4: Creating ViewModels

    If my assumption is wrong, you experience any difficulties or have additional questions, do not hesitate to get back to us.

     

    Regards,
    Doroteya
    the Telerik team
    Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.
  6. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 26 Mar 2013 Link to this post

    Hi Doroteya

    I have looked into the ORM example and been unable to find an example of a fetch plan in use. As requested before please provide an example of a fetchplan for a parent and child setup.

    regards
    mike
  7. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 29 Mar 2013 Link to this post

    Hi Mike,

    In this video you can find an end-to-end tutorial how to create a Silverlight application that consumes a domain model through a WCF Ria Service generated by OpenAccess. The second half of the video demonstrates how the service can be extended with custom methods and how these custom methods can be used in the UI.

    I suggest that use this video as a template for your scenario and apply the necessary logic in the body of the custom methods of the service.

    I hope that works for you. If you have other questions, do not hesitate to get back to us.


    Regards,
    Doroteya
    the Telerik team
    Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.
  8. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 29 Mar 2013 Link to this post

    Hi, thank you for the video.

    But my issue still remains. I need to know how to use the fetchplan. This is specific to Telerik. Neither the ORM sample or this video provide the info I need to properly display the data of the fetchplan to the parent and child grid. I can only deduce that this documentation does not exist.

    I have spent almost 3 months trying to come to grips with Open access ORM. I can not afford to any longer. I have decided to go back to EF and the default in Ria services. I am at least able to find info on the net about it when needed.

    regards

    mike
  9. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 03 Apr 2013 Link to this post

    Hi Mike,

    While the FetchStrategy which was recommended in one of our previous posts is something specific for OpenAccess ORM, used to define what relationships should be eagerly loaded on the server side, loading related data with RIA services is a generic RIA services issue. Nevertheless, there are is an example that should help you achieve that - the quick-start for working with RIA services, which can be found here. On this step of the tutorial it is explained how you can load related data.

    I hope that helps

    Kind regards,
    Ivailo
    the Telerik team 
Back to Top
DevCraft banner