Complex Rules Apply to a Entity

I have an Entity, called, Student which contains Id(INT), StudentID(INT), Name(TEXT), Age(INT), Active(bool)

Basically looks like this

Database: Student

 |  ID  |  StudentID  |  Name  |  Age  |  Active   |
|    1  |    100          |  John   |   21   |    True   |
|    2  |    101          |  Dave  |   23   |    True   |
|    3  |    102          |  Ross  |   23   |    True   |
|    4  |    103          |  Jane  |   22   |    True   |

There will be certain condition that will apply when I output the list onto a table
For example, it can be:
UPDATE {Student} SET [Active] = 0 WHERE [Age] > 22
UPDATE {Student} SET [Active] = 0 WHERE [Name] Like 'J%' (Starts With J, I know the syntax is wrong here)
But I dont want these conditions to be hardcoded as I want them to be dynamic and my client will define these rules.
The way I want to do this is by creating a form which allows my client to fill

DropDown Variable(StudentID/Name/Age) | Criteria(= / > / < / <= / >= / != ) | Value (textbox, ie: 0) | Active (True or False) . And they can add multi rules and these rules will be saved into another table which I will also show what rules they have applied

This essentially is like Filtering function in Excel

How can I achieve doing this? Originally in .NET, Visual Studio, I would write a stored procedure for it. But I dont see how Service Studio able to create a stored procedure

Hi David,

That can be done with an advanced query with some expand inline parameters. To refer to the entities and attributes you can still use the usual advanced query syntax inside the parameters values.

But you need to be really carefull with the values you accept and make sure you sql escape them correctly.
Using expand inline is dangerous because you the automatic escaping of those parameters.
Use it carefully :)

João Rosado
Hi Joao thanks for your reply, I should add alittle bit more to my questions

I will also have a rule table 

|  ID  |  Variable  |  Criteria           |  Value  |  Action  |
|    1  |    Age      |  Greater Than |   22      |    True   |
|    2  |    Name   |  Begins with     |   J         |    False |

These rules are not pre-set as I am just giving an example that my client would add, and the list can grow

The reason I have a this rule table is because I want to keep track of these rules

Each time a rule has been added, it will update the student table, active column, whether if its true or false, and if the rule is deleted, it will undo the changes