DataContext GetTable by parameter string name

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

    Posted 14 Jan 2015 Link to this post

    Hello

    i would to get the Entity Object table, like this.

    oTable = this.DbContext.GetTable("MyTable")

    Why i don't find this method in Data Access like microsoft ?

    http://msdn.microsoft.com/fr-fr/library/bb357220%28v=vs.110%29.aspx

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

    Posted 16 Jan 2015 Link to this post

    Hi Olivier,

    Thank you for contacting us.

    Usually when using Telerik Data Access records from the database are retrieved using LINQ using the model`s context like show in this documentation article. The database records are materialized to their respective persistent type and depending on the used LINQ statements the result can be a single object or a collection of multiple objects.

    If your goal is to be able to retrieve objects from the database using a string name, you can make use of our Artificial API for read operations. Using it you can retrieve persistent objects using their full type name (namespace included). For example if you have a table Cars in your database and respectively a Car persistent type in your model which resides in the EntitiesModel namespace you can use the following line to retrieve Car objects:
    var allCars = context.GetAll("EntitiesModel.Car");

    Please note that you must use the name of the persistent class responsible for the respective table. You cannot use the name of the table itself to retrieve records using this API.

    For more information about performing CRUD operations using the Artificial API please refer to this documentation section.

    In case your reason for wanting to use a method similar to GetTable is different, could you please provide us with more details about it as well as your specific scenario? This will help us better aid you in resolving the situation.

    We are looking forward to your feedback.

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