How to use a string literal to specify a column name in SubSonic 3.0

subsonic

Here is a statement in SubSonic which does a find using the strongly typed column ProductId:

var products = Product.Find(x => x.ProductID <= 10);

Is there a way to not use a strongly typed column name and instead specify the column name with a string literal like so:

var columnName = "SampleColumn";
var products = Product.Find(x => x[columnName] <= 10);

Or something similar?

Best Answer

You can't do this with linq but you could do it using a fluent query as follows:

string columnName = "SampleColumn";

List<Product> products = new Select()
  .From<Product>()
  .Where(columnName).IsLessThanOrEqualTo(10)
  .ExecuteTypedList<Product>();