I have a configuration table that contains various configurations for permissions to show various data a e.g.
PermissionTable
key1 key2 showconfig1 showconfig2
1 A Y N
2 B N N
3 C Y Y
An application of various webservices make queries at different points in the code to the same table to get values from different showconfig columns for permissions.
How can I create a generic centralized query where the app can pass the key1 value , the key2value and a columnName variable to get the value of a particular column row without having to write a separate query to query each column row or without having to write a query to retrieve all the columns values for a particular row?
e.g. the following just returns the column name I want the value in that column:
public string GetPermission(int key1, int key2 ,string columnName)
{
string show = "N";
var show = (from p in db.PermissionTable
where p.key1== key1
&& p.key2 == key2
select p.[columnName]).FirstOrDefault().ToString();
return show;
}