Ejemplo n.º 1
0
        public SqlBuilder FilterA(string column, Int32ExParameter 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} IS NULL OR {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 ({Param(value.In)})");
            }

            if (value.Ni != null)
            {
                AppendFilter($@"({column} IS NULL OR NOT ({column} = ANY ({Param(value.Ni)})))");
            }

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

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

            if (value.Null != null)
            {
                AppendFilter(value.Null == true
                    ? $@"{column} IS NULL"
                    : $@"{column} IS NOT NULL");
            }

            return(this);
        }
Ejemplo n.º 2
0
        public SqlBuilder Filter(string column, Int32ExParameter 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}"" IS NULL OR ""{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($@"(""{column}"" IS NULL OR NOT (""{column}"" = ANY (@p{Counter})))");
                Params.Add($"p{Counter++}", value.Ni);
            }

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

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

            if (value.Null != null)
            {
                AppendFilter(value.Null == true
                    ? $@"""{column}"" IS NULL"
                    : $@"""{column}"" IS NOT NULL");
            }

            return(this);
        }