score:1

Accepted answer

define base query which will return db.if_table. after that build the query around this result. this 3 if on your result should cover all of your cases.

        iqueryable<if_table> result = db.if_table;
        if (!string.isnullorempty(col1))
        {
             result = result.where(x => x.col1 == col1);
        }
        if (!string.isnullorempty(col2))
        {
            result = result.where(x => x.col2 == col2);
        }
        if (!string.isnullorempty(col3))
        {
            result = result.where(x => x.col3 == col3);
        }

if you want empty datatable to be return when all col1, col2, col3 are empty string or null. you can define bool variable filltable and set it to true in the if statements. after the ifs you can check if(!filltable)return dt;


Related Query

More Query from same tag