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

Get table Name from object entity telerik Data Access

3 Answers 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Olivier
Top achievements
Rank 2
Olivier asked on 15 Jan 2015, 04:14 PM
Hello

How i can get the table name, from a entity object telerik data access ?

EntitiesModel.MyObject.GetTableName() ?

thanks
Olivier

3 Answers, 1 is accepted

Sort by
0
Kristian Nikolov
Telerik team
answered on 20 Jan 2015, 09:44 AM
Hi Olivier,

You can use an instance of your context class (the one deriving from OpenAccessContext) to access the metadata for your model and retrieve the name of the table for a certain persistent type. Consider the following example illustrating how to retrieve the name of the table responsible for the Car persistent type:
string carTableName = context.Metadata.PersistentTypes.FirstOrDefault(typ => typ.FullName == typeof(Car).FullName).Table.Name;
Similarly you can retrieve the names for the tables of all persistent types:
var allTableNames = context.Metadata.PersistentTypes.Select(typ => typ.Table.Name).ToList();

I hope this helps. In case you have any more questions, feel free to get back to us.

Regards,
Kristian Nikolov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Olivier
Top achievements
Rank 2
answered on 20 Jan 2015, 02:00 PM
Hello Kristian,

it's great, thanks very much !

i ll post my code about the other question to get a good dynamically Linq for telerik data access.

Olivier
0
Kristian Nikolov
Telerik team
answered on 23 Jan 2015, 02:04 PM
Hello Olivier,

We are glad this is working out for you.

Do not hesitate to get back to us in case you have further questions or need help with Telerik Data Access.

Regards,
Kristian Nikolov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Olivier
Top achievements
Rank 2
Answers by
Kristian Nikolov
Telerik team
Olivier
Top achievements
Rank 2
Share this question
or