Metadata classes creation !!

4 posts, 1 answers
  1. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 16 Apr 2011 Link to this post

    Dear All,

    I have two questions:

    1- Is there an automated way to create the meta-data class for OA domain model?
    2- How to convert the self-reference relation from EF to OA; I have tried this and i want to make sure it is correct:
    I have created an Association on the table as follows:
    Parent : Type of the table
    Children IList<table> and I got then generated at the class.
    But I can't see how to access it like EF doing the following:
    public IQueryable<group> GetChildrenByParentID(int ID)
    {
    return this.ObjectContext.group.Include("Children").Where(p => p.id == ID);
    }

    Any help !!
    Best
  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 20 Apr 2011 Link to this post

    Hi Ubuntu,

     If you are referring this kind of metadata classes then there is no automatic way to do this. Other than perhaps extending the T4 templates that are used for code generation or writing your own. You can have a look at this help article in order to see how templates are usually extended. This however seems like too much work for such a task.  

    When using OpenAcess you needn't worry about loading related entities as everything is lazy loaded, which means that it be loaded when requested, and if you need it early on, you can have a look at our Fetch Plan API. This is regarding the Include clause that Entity Framework provides.

    In order to achieve something similar I will suggest having a look at your context implementation (the one generated by the rlinq) and extent that exact class in another partial. 

    I hope this proves to be helpful and I will be more than glad to help if you face further trouble or find something not clear enough. 

    Greetings,
    Serge
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 20 Apr 2011 Link to this post

    Hello Serge,

    I appreciate your reply.

    Actually, I don't think you understood my question, or I wasn't clear.
    Let me re-phrase it again please, in this code - the bold part - how to have the same in OA:
    public IQueryable<group> GetChildrenByParentID(int ID)
    {
    return this.ObjectContext.group.Include("Children").Where(p => p.id == ID);
    }

    Or in another way: I need to have my tree (self-reference table) implementation ..is there any other way in here ...

    best regards
  5. Answer
    Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 22 Apr 2011 Link to this post

    Hello Ubuntu,

     I believe you are trying to Load a group object together with its Children collection. That can be achieved, as Serge said, with the Fetch Plan API of OpenAccess. At the moment we do not have the exact API to fetch children objects directly in the Linq query, but this is part of our TODO list. For now yo can achieve the same goal using the following code:

    public IQueryable<group> GetChildrenByParentID(int ID)
    {
       FetchStrategy fetchStrategy = new FetchStrategy();
       fetchStrategy.LoadWith<group>(c => c.Children);
       this.ObjectContext.FetchStrategy = fetchStrategy;
     
       return this.ObjectContext.group.Where(p => p.id == ID);
    }


    Best wishes,
    Zoran
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top