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

Table name as a parameter

3 Answers 109 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.
bin
Top achievements
Rank 1
bin asked on 13 Apr 2011, 01:40 PM
Hi sir,

i am using the ObjectScope of  telerik open access.

How can i select data by sending the table name as parameter using linq query ?

thanks

3 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 15 Apr 2011, 04:18 PM
Hi bin,

 Unfortunately at the moment it is impossible to retrieve information based on the table name. However it should be possible to retrieve the persistent type name based on the table name using the metadata model that is available trough the scope. 

You can do so using code like: 

var model = scope.Database.MetaData;
string tableName = "table-name";
 
var persistentType = model.PersistentTypes
    .FirstOrDefault(x => x.Table != null && string.Equals(x.Table.Name, tableName));
string typeName = persistentType.FullName;

However this might only help you if you are using OQL to retrieve data. 

I hope this is helpful. 

All the best,
Serge
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
0
XXXX
Top achievements
Rank 1
answered on 13 May 2011, 02:52 PM
This is of interest to me as I want to query a table that is not part of the DomainModel.

Using IObjectScope.GetSqlQuery will be database depentant and I would like to solve this without having diffrent queries depending what the backend type is.

Has anyone a workaround ?
0
Alexander
Telerik team
answered on 17 May 2011, 05:23 PM
Hello Bjössi,

I am afraid that the only way to retrieve information from a table which is not part of the model is to create a stored procedure in the database which returns the needed data. Then you can add this stored procedure to your model and execute it as a method of the OpenAccessContext instance. This method would return an object array which you can easily traverse to get the data.

Regards,
Alexander
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Tags
LINQ (LINQ specific questions)
Asked by
bin
Top achievements
Rank 1
Answers by
Serge
Telerik team
XXXX
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or