I want to make where class dynamic. When someone will call this function then I don't know the total numbers of parameters and comparison operator(e.g equalto, greaterthen etc) and field-names as well.How can I achieve this?
In this example I am using three parameters. "PartitionKey","RowKey" and tableName.It may be 0 or any numbers and Also it can be any like "FirtName", "Age" etc
public void Persons(string whereClauseParameters)
{
var query = (from p in cloudTable.CreateQuery<CustomTableEntity>()
where p.PartitionKey == "" && p.RowKey != "" && p.TableName == ""
select p);
}
It sounds you're looking for something like Dynamic Linq. This allows you to do queries like:
var query = northwind.Products
.Where("CategoryID = 3 AND UnitPrice > 3")
.OrderBy("SupplierID");
where the fields can be specified as dynamic strings, instead of 'hard-coded'.