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

Metadata classes creation !!

3 Answers 89 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ubuntu
Top achievements
Rank 1
Ubuntu asked on 16 Apr 2011, 01:31 PM
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

3 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 20 Apr 2011, 12:09 PM
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
0
Ubuntu
Top achievements
Rank 1
answered on 20 Apr 2011, 12:16 PM
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
0
Accepted
Zoran
Telerik team
answered on 22 Apr 2011, 06:29 AM
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
Tags
Getting Started
Asked by
Ubuntu
Top achievements
Rank 1
Answers by
Serge
Telerik team
Ubuntu
Top achievements
Rank 1
Zoran
Telerik team
Share this question
or