get my original database table's name

Thread is closed for posting
3 posts, 1 answers
  1. xu
    xu avatar
    11 posts
    Member since:
    Oct 2008

    Posted 19 Mar 2010 Link to this post

    How do I get my original database table's name and  primary key's name?
  2. Sergej Mertens
    Sergej Mertens avatar
    34 posts
    Member since:
    May 2009

    Posted 22 Mar 2010 Link to this post

    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

  3. Answer
    PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 23 Mar 2010 Link to this post

    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.
Back to Top