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

DataContext GetTable by parameter string name

1 Answer 294 Views
LINQ (LINQ specific questions)
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 14 Jan 2015, 01:53 PM
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

1 Answer, 1 is accepted

Sort by
0
Kristian Nikolov
Telerik team
answered on 16 Jan 2015, 03:20 PM
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.
 
Tags
LINQ (LINQ specific questions)
Asked by
Olivier
Top achievements
Rank 2
Answers by
Kristian Nikolov
Telerik team
Share this question
or