Writing a method that will accept table as an input
I want to write a method that can accept a table as input, i.e.:
void Take_something_from_table(string table_name)
{
DataClassesDataContext 开发者_开发问答dc = new DataClassesDataContext();
var queryResult = from a in dc.GetTable<*table_name*>() //without * of course
select a;
...
}
I want a method that will be called Take_something_from_table(Test_table)
I tried this and got this error:
The type or namespace name 'table_name' could not be found (are you missing a using directive or an assembly reference?)
HELP!!
i agree with leppie, or if u wana keep that string as table name then define and enum or else and place If Else block to perform action. for example
if(TabmeNameA)
{
// Execute Query for table A
}
if(TabmeNameB)
{
// Execute Query for table B
}
精彩评论