Build query using strings ?
-
Hi all , I want to pass the table name as parameter to the method to obtain the result. The code is as follows:-
private static String GetText(int id , String tableName) { tbTest myTest = new tbTest(); // I want to create this dynamically using the table name provided in the parameter ? myTest = dataContext.tbTests.Single(table => table.Test_id == id); return myTest.Test_Text; }
Is there anyway where-in I can pass the id and table name to obtain the corresponding text (probably by strings ??) ? I hope it makes sense. thanks, -
Hi all , I want to pass the table name as parameter to the method to obtain the result. The code is as follows:-
private static String GetText(int id , String tableName) { tbTest myTest = new tbTest(); // I want to create this dynamically using the table name provided in the parameter ? myTest = dataContext.tbTests.Single(table => table.Test_id == id); return myTest.Test_Text; }
Is there anyway where-in I can pass the id and table name to obtain the corresponding text (probably by strings ??) ? I hope it makes sense. thanks,What? Is this a database question? We need more information.
-
Hi all , I want to pass the table name as parameter to the method to obtain the result. The code is as follows:-
private static String GetText(int id , String tableName) { tbTest myTest = new tbTest(); // I want to create this dynamically using the table name provided in the parameter ? myTest = dataContext.tbTests.Single(table => table.Test_id == id); return myTest.Test_Text; }
Is there anyway where-in I can pass the id and table name to obtain the corresponding text (probably by strings ??) ? I hope it makes sense. thanks, -
Hi all , I want to pass the table name as parameter to the method to obtain the result. The code is as follows:-
private static String GetText(int id , String tableName) { tbTest myTest = new tbTest(); // I want to create this dynamically using the table name provided in the parameter ? myTest = dataContext.tbTests.Single(table => table.Test_id == id); return myTest.Test_Text; }
Is there anyway where-in I can pass the id and table name to obtain the corresponding text (probably by strings ??) ? I hope it makes sense. thanks,dataContext.GetTable()
[^] perhaps? /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
What? Is this a database question? We need more information.
I want to create and execute a dynamic query in the method by passing in the table name and ID. I hope it makes sense.?
-
If you mean that the parameter tableName will be the name of class whose object you need to create, you can make use of reflection.
Reflection? I havnt used that before...can u elaborate on it plz. Thanks
-
I want to create and execute a dynamic query in the method by passing in the table name and ID. I hope it makes sense.?
It makes sense, but it isn't enough information.
-
It makes sense, but it isn't enough information.
Please let me know wat info do u require?
private static String GetText(int id , String tableName) { // I want to pass the name of table as String to dynamically initialize the actual table here // for example if I pass the table name as "tbName" i would like to create something like this // tbName myName = new tbName(); // and then the next line as myName = dataContext.tbNames.Single(table => table.Name_id == id) // and finally return myName.Name_Text as output. tbTest myTest = new tbTest(); // I want to create this dynamically using the table name provided in the parameter ? myTest = dataContext.tbTests.Single(table => table.Test_id == id); return myTest.Test_Text; }
I want the code to return the appropriate Text depending on the parameters passed ie tableName and ID -
Please let me know wat info do u require?
private static String GetText(int id , String tableName) { // I want to pass the name of table as String to dynamically initialize the actual table here // for example if I pass the table name as "tbName" i would like to create something like this // tbName myName = new tbName(); // and then the next line as myName = dataContext.tbNames.Single(table => table.Name_id == id) // and finally return myName.Name_Text as output. tbTest myTest = new tbTest(); // I want to create this dynamically using the table name provided in the parameter ? myTest = dataContext.tbTests.Single(table => table.Test_id == id); return myTest.Test_Text; }
I want the code to return the appropriate Text depending on the parameters passed ie tableName and IDWhat you've presented is gibberish to me. I want to know what you are trying to accomplish, not how you are trying to accomplish it (especially if it doesn't work). 0) Is there a database? 1) Is there a table in the database? 2) Are you trying to retrieve some information from that database table? 3) What is the schema of the table?