mercredi 1 août 2018

How to check if statements dynamically from database

My questions as follows, I need to check conditions through the database. which means in the simple application we check if conditions like this.

private static void Main(string[] args)
{
    Console.WriteLine("Enter your age");
    var age = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());

    if (5 <= age && age <= 10)
    {
        Console.WriteLine("Range 5 - 10");
    }else if (11 <= age && age <= 20)
    {
        Console.WriteLine("Range 11 - 20");
    }
    else if (21 <= age && age <= 30)
    {
        Console.WriteLine("Range 21 - 30");
    }
    else
    {
        Console.WriteLine("Over range");
    }
}

Suppose, Client, needs to change the condition dynamically, which means he need to add aditional condtion to the system like,

if 31 <= age && age <= 40 => Range 31 - 40

When doing this in the client side, sometimes wrong conditions can be added to the system like,

(4 <= age && age <= 15) this condition cannot be added, because the system already have condition (5 <= age && age <= 10). When age is 7, both conditions will be true. like this type situations what is the best thing to do.

I need to store the conditions in my database,(PS:database table structure can be changed according to your answer)

as the sample table structure

ConditionID    Condition                  Details

con001         5 <= age && age <= 10      Range 5 - 10
con002         11 <= age && age <= 20     Range 11 - 20
con003         21 <= age && age <= 30     Range 21 - 30

Please give me a solution to solve this. How can I do this with C# and oracle SQL

Aucun commentaire:

Enregistrer un commentaire