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

get my original database table's name

2 Answers 70 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.
xu
Top achievements
Rank 1
xu asked on 19 Mar 2010, 10:47 AM
How do I get my original database table's name and  primary key's name?

2 Answers, 1 is accepted

Sort by
0
Sergej Mertens
Top achievements
Rank 1
answered on 22 Mar 2010, 10:46 AM
Hi xu,

if your question targets the meta data of your database, then this could easily be done with the Metadata-API. Just open a connection and use the Metedata property of the Database object:
var meta = ObjectScopeProvider1.Database().Metedata;

The there are properties for tables etc.

Greetings,
Daniel

0
Accepted
PetarP
Telerik team
answered on 23 Mar 2010, 06:13 PM
Hello xu,

What Daniel suggested is the correct approach. You can easily perform linq queries against our Metadata container that will retrieve the information you require. For example if you would like to find the original table name for the class Customer this is what you need to do:
NorthwindOAEntityDiagrams db = new NorthwindOAEntityDiagrams();
            MetadataContainer container = db.Metadata;
            string tableName = container.PersistentTypes.Where(c => c.Name.Equals("Customer")).Select(c => c.Table.Name).First();

Greetings,
Petar
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
General Discussions
Asked by
xu
Top achievements
Rank 1
Answers by
Sergej Mertens
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or