Is it possible to query a user-specified column name without resorting to dynamic SQL?
问题 I am trying to implement an API with the following signature: public static List<string> SearchDatabase( string column, string value); The implementation of the API needs to construct an SQL SELECT query with a WHERE clause that uses a column name specified in the column parameter. The query: string query = string.Format( "SELECT Name, @Column " + "FROM Db1 " + "INNER JOIN Db2 ON Db1.Id = Db2.Id " + "WHERE @Column = @Value"); The SQL command and parameters: SqlCommand selectCmd = new