Reputation: 2433
This brings the column names of Person table:
var query = from t in typeof(Person).GetProperties() select t.Name;
How can I parametrize the typeof's argument. Like:
string tableName="Employee";
var query = from t in typeof(tableName).GetProperties() select t.Name;
Upvotes: 0
Views: 2850
Reputation: 101681
You can use Type.GetType
method which takes a string parameter
var query = from t in Type.GetType(tableName).GetProperties() select t.Name;
BTW you should pass type's fully qualified name
to this method.That means you should specify namespace
+ class name
.
Upvotes: 3