示例#1
0
文件: SqlBuilder.cs 项目: yepeek/tzkt
        public SqlBuilder FilterA(string column, AccountParameter account, Func <string, string> map = null)
        {
            if (account == null)
            {
                return(this);
            }

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

            if (account.Ne != null && account.Ne != -1)
            {
                AppendFilter($"({column} IS NULL OR {column} != {account.Ne})");
            }

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

            if (account.Ni != null && account.Ni.Count > 0)
            {
                AppendFilter($"({column} IS NULL OR NOT ({column} = ANY (@p{Counter})))");
                Params.Add($"p{Counter++}", account.Ni);
            }

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

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

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

            return(this);
        }
示例#2
0
        public SqlBuilder Filter(string column, AccountParameter account, Func <string, string> map = null)
        {
            if (account == null)
            {
                return(this);
            }

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

            if (account.Ne != null && account.Ne != -1)
            {
                AppendFilter($@"""{column}"" != {account.Ne}");
            }

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

            if (account.Ni != null && account.Ni.Count > 0)
            {
                AppendFilter($@"NOT (""{column}"" = ANY (@{column}Ni))");
                Params.Add($"{column}Ni", account.Ni);
            }

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

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

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

            return(this);
        }