Beispiel #1
0
        public static Int32Parameter FromDateTimeParameter(DateTimeParameter timestamp, TimeCache time)
        {
            if (timestamp == null)
            {
                return(null);
            }

            var res = new Int32Parameter();

            if (timestamp.Eq != null)
            {
                res.Eq = time.FindLevel((DateTime)timestamp.Eq, SearchMode.Exact);
            }

            if (timestamp.Ne != null)
            {
                res.Ne = time.FindLevel((DateTime)timestamp.Ne, SearchMode.Exact);
            }

            if (timestamp.Gt != null)
            {
                res.Gt = time.FindLevel((DateTime)timestamp.Gt, SearchMode.ExactOrLower);
            }

            if (timestamp.Ge != null)
            {
                res.Ge = time.FindLevel((DateTime)timestamp.Ge, SearchMode.ExactOrLower);
            }

            return(res);
        }
Beispiel #2
0
        public SqlBuilder FilterA(string column, Int32Parameter value, Func <string, string> map = null)
        {
            if (value == null)
            {
                return(this);
            }

            if (value.Eq != null)
            {
                AppendFilter($@"{column} = {value.Eq}");
            }

            if (value.Ne != null)
            {
                AppendFilter($@"{column} != {value.Ne}");
            }

            if (value.Gt != null)
            {
                AppendFilter($@"{column} > {value.Gt}");
            }

            if (value.Ge != null)
            {
                AppendFilter($@"{column} >= {value.Ge}");
            }

            if (value.Lt != null)
            {
                AppendFilter($@"{column} < {value.Lt}");
            }

            if (value.Le != null)
            {
                AppendFilter($@"{column} <= {value.Le}");
            }

            if (value.In != null)
            {
                AppendFilter($@"{column} = ANY (@p{Counter})");
                Params.Add($"p{Counter++}", value.In);
            }

            if (value.Ni != null)
            {
                AppendFilter($@"NOT ({column} = ANY (@p{Counter}))");
                Params.Add($"p{Counter++}", value.Ni);
            }

            return(this);
        }
Beispiel #3
0
        public SqlBuilder Filter(string column, Int32Parameter value, Func <string, string> map = null)
        {
            if (value == null)
            {
                return(this);
            }

            if (value.Eq != null)
            {
                AppendFilter($@"""{column}"" = {value.Eq}");
            }

            if (value.Ne != null)
            {
                AppendFilter($@"""{column}"" != {value.Ne}");
            }

            if (value.Gt != null)
            {
                AppendFilter($@"""{column}"" > {value.Gt}");
            }

            if (value.Ge != null)
            {
                AppendFilter($@"""{column}"" >= {value.Ge}");
            }

            if (value.Lt != null)
            {
                AppendFilter($@"""{column}"" < {value.Lt}");
            }

            if (value.Le != null)
            {
                AppendFilter($@"""{column}"" <= {value.Le}");
            }

            if (value.In != null)
            {
                AppendFilter($@"""{column}"" = ANY (@{column}In)");
                Params.Add($"{column}In", value.In);
            }

            if (value.Ni != null)
            {
                AppendFilter($@"NOT (""{column}"" = ANY (@{column}Ni))");
                Params.Add($"{column}Ni", value.Ni);
            }

            return(this);
        }