Get table Name from object entity telerik Data Access

4 posts, 0 answers
  1. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 15 Jan 2015 Link to this post

    Hello

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

    EntitiesModel.MyObject.GetTableName() ?

    thanks
    Olivier
  2. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 20 Jan 2015 Link to this post

    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.
     
  3. DevCraft banner
  4. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 20 Jan 2015 in reply to Kristian Nikolov Link to this post

    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
  5. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 23 Jan 2015 Link to this post

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