.netormmassive

Massive ORM dynamic Where filtering


Since there is not much documentation on this, could someone tell if there is a way of filtering data dynamically, given that there are lot of filter options ?


Solution

  • The solution is actually really simple if anyone has the same question, if there is a better way please let me know:

            string query = "select * from pandas where panda_id = :0";
            List<object> parameters = new List<object>();
            parameters.Add(15162210);
    
            //  Apply filter
            if(shouldSearchByName)
            {
                query += " and name = :1";
                parameters.Add("Super Panda");
            }
    
            // Return the data
            return DB.Current.Query( query, args:parameters.ToArray());