当前位置: 首页>>代码示例>>C#>>正文


C# WhereClause.AddClause方法代码示例

本文整理汇总了C#中WhereClause.AddClause方法的典型用法代码示例。如果您正苦于以下问题:C# WhereClause.AddClause方法的具体用法?C# WhereClause.AddClause怎么用?C# WhereClause.AddClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WhereClause的用法示例。


在下文中一共展示了WhereClause.AddClause方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClanInfo

        /// <summary>
        /// This request provides claninfo to the bf2server, to set the filter rules
        /// for players joining the server.
        /// </summary>
        /// <queryParam name="type" type="int">The Listype (whitelist, blacklist)</queryParam>
        /// <queryParam name ="clantag" type="string">Specified the required clantag</queryParam>
        /// <queryParam name="score" type="int">The minimum required score</queryParam>
        /// <queryParam name="rank" type="int">The minimum required ranked</queryParam>
        /// <queryParam name="time" type="int">The minimum required global time</queryParam>
        /// <queryParam name="kdratio" type="float">The minimum required kill/death ratio</queryParam>
        /// <queryParam name="country" type="string">The country code (Ex: us, br, no) required, seperated by comma, that is required</queryParam>
        /// <queryParam name="banned" type="int">Specified the maximum ban count to be accepted into the list</queryParam>
        /// <param name="Client">The HttpClient who made the request</param>
        /// <param name="Driver">The Stats Database Driver. Connection errors are handled in the calling object</param>
        public GetClanInfo(HttpClient Client, StatsDatabase Database)
        {
            int Type = 0;
            Dictionary<string, string> QueryString = Client.Request.QueryString;
            Driver = Database;

            // make sure we have a valid player ID
            if (!QueryString.ContainsKey("type") || !Int32.TryParse(QueryString["type"], out Type))
            {
                Client.Response.WriteResponseStart(false);
                Client.Response.WriteHeaderLine("asof", "err");
                Client.Response.WriteDataLine(DateTime.UtcNow.ToUnixTimestamp(), "Invalid Syntax!");
                Client.Response.Send();
                return;
            }

            // Filler Variables
            int I = 0;
            float F;
            string S;
            List<DbParameter> Params = new List<DbParameter>();

            // Prepare Query
            SelectQueryBuilder Query = new SelectQueryBuilder(Driver);
            Query.SelectColumns("id", "name");
            Query.SelectFromTable("player");
            Query.SetWhereOperator(LogicOperator.And);
            Query.AddWhere("ip", Comparison.NotEqualTo, "0.0.0.0");
            Query.AddOrderBy("id", Sorting.Ascending);
            WhereClause Where = null;

            switch (Type)
            {
                // Blacklist
                case 0:
                    int BanLimit = (QueryString.ContainsKey("banned") && Int32.TryParse(QueryString["banned"], out I)) ? I : 100;
                    Where = new WhereClause("banned", Comparison.GreaterOrEquals, BanLimit);
                    Where.AddClause(LogicOperator.Or, "permban", Comparison.Equals, 1);
                    break;
                // Whitelist
                case 1:
                    if (QueryString.ContainsKey("clantag"))
                    {
                        Where = new WhereClause("clantag", Comparison.Equals, QueryString["clantag"]);
                        Where.AddClause(LogicOperator.And, "permban", Comparison.Equals, 0);
                    }
                    break;
                // Greylist
                case 2:
                    // List of possible query's
                    string[] Queries = new string[] { "score", "rank", "time", "kdratio", "country", "banned" };
                    foreach (string Param in Queries)
                    {
                        if (QueryString.ContainsKey(Param))
                        {
                            switch (Param)
                            {
                                case "score":
                                case "time":
                                case "rank":
                                    if (Int32.TryParse(QueryString[Param], out I))
                                    {
                                        if (Where == null)
                                            Where = new WhereClause(Param, Comparison.GreaterOrEquals, I);
                                        else
                                            Where.AddClause(LogicOperator.And, Param, Comparison.GreaterOrEquals, I);
                                    }
                                    break;
                                case "kdratio":
                                    if (float.TryParse(QueryString["kdratio"], out F))
                                    {
                                        if (Where == null)
                                            Where = new WhereClause("(kills / deaths)", Comparison.GreaterOrEquals, F);
                                        else
                                            Where.AddClause(LogicOperator.And, "(kills / deaths)", Comparison.GreaterOrEquals, F);
                                    }
                                    break;
                                case "country":
                                    S = QueryString["country"].Replace(",", "','");
                                    if (Where == null)
                                        Where = new WhereClause(Param, Comparison.In, S.Split(','));
                                    else
                                        Where.AddClause(LogicOperator.And, Param, Comparison.In, S.Split(','));
                                    break;
                                case "banned":
                                    if (Int32.TryParse(QueryString["banned"], out I))
//.........这里部分代码省略.........
开发者ID:roguesupport,项目名称:ControlCenter,代码行数:101,代码来源:GetClanInfo.cs

示例2: AdvancedSearchQuery


//.........这里部分代码省略.........
        {
            Query.AddWhere("fa_group", Comparison.Equals, fagroup_db);
        }

        if (NarLogText.Length > 2)
        {
            if (Incidentdt.Date < Controldt.Date)
            {
                Query.AddWhere("nar_log_text", Comparison.Like, "TEXT");
            }
            else
            {
                Query.AddWhere("nar_log_entry", Comparison.Like, "Log Entry");
            }

        }

        else
        {
            // do nothing
        }

        if (NarLogText.Length > 1 && NarrtiveSplit.Length < 2)
        {
            clause = Query.AddWhere("nar_log_text", Comparison.Like, new SqlLiteral("'%" + NarLogText.ToUpper() + "%'"));
        }

        if (NarLogText.Length > 1 && NarrtiveSplit.Length >= 2)
        {
            clause = Query.AddWhere("nar_log_text", Comparison.Like, "SQLworkaround");

            foreach (string t in NarrtiveSplit)
            {
                clause.AddClause(LogicOperator.Or, Comparison.Like, "%" + t + "%");
            }
        }

        else
        {
            if (NarLogText.Length == 0)
            {
                //clause = Query.AddWhere("nar_log_text", Comparison.Like, new SqlLiteral("'%" + tb_NarLogSearch.Text.ToUpper() + "%'"));
            }
        }

        if (IncidentNumber.Length > 2)
        {
            Query.AddWhere("id_in_ref", Comparison.Equals, IncidentNumber);
        }

        if (oicincname.Length > 2)
        {
            Query.AddWhere("oic_inc_name", Comparison.Like, "%" + oicincname.ToUpper() + "%");
        }

        if (OfficerCallSign_search.Length > 1)
        {
            Query.AddWhere("MB_CALL_SIGN", Comparison.Equals, OfficerCallSign_search);
        }

        if (ADI_search.Length > 4)
        {
            Query.AddWhere("Adi_General", Comparison.Like, "%" + ADI_search + "%");
        }

        if (CauseofFire_search.Length > 3)
开发者ID:Hughesm,项目名称:IQT-Tool,代码行数:67,代码来源:AdvIRSClasses.cs


注:本文中的WhereClause.AddClause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。