Looking for a wayt to dynamically query the database by field names

I can use autoquery since I’m just using the servicestack orm. and not servicestack services.
The kind of query API that I’m after is to be able to chain field names, values, and comparers dynamically.

for example:

From<T>().Where("Id", Comparer.GraterThen, 10)
       .AndWhere("FullName", Comparer.StartsWith, "A")
       .AndWhere("CountryCode", Comparer.In, "US,GB".Split(",")).Select("*")

This is just an example, but basicaly this is what I am getting from my client side…

Possible somehow?


If this is to build a dynamic Service than look at AutoQuery first as it enables dynamic querying.

Otherwise you’d need to invent that Query API language itself, behind the scenes you can call the AddCondition API, e.g:

var q = db.From<T>()
  .AddCondition("AND","Id < {0}", 10)
  .AddCondition("AND","Fullname LIKE {0}", "A%")
  .AddCondition("OR","CountryCode IN ({0})",new SqlInValues("US,GB".Split(",")));

var results = db.Select(q);

Or you can also call Where(sqlFragment), And(sqlFragment) or Or(sqlFragment) if you prefer, these APIs include common SQL verification, if you need to bypass SQL Verification for a query you can call UnsafeWhere(sqlFragment), UnsafeAnd(sqlFragment) or UnsafeOr(sqlFragment).

There is no way to use the auto-query without servicestack? something like stand-alone api?

No, it’s a ServiceStack plugin.