當前位置: 首頁>>代碼示例>>C#>>正文


C# Result.AddRow方法代碼示例

本文整理匯總了C#中System.Result.AddRow方法的典型用法代碼示例。如果您正苦於以下問題:C# Result.AddRow方法的具體用法?C# Result.AddRow怎麽用?C# Result.AddRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Result的用法示例。


在下文中一共展示了Result.AddRow方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Select

        public Result Select(string sql)
        {
            List<string> fields = new List<string>();

            string fieldset = sql.Split(new string[] { "FROM" }, StringSplitOptions.None)[0].Replace("SELECT", "");
            string[] sf = fieldset.Split(',');
            foreach (string item in sf)
            {
                string adder = "";
                if (item.ToLower().Contains(" as "))
                {
                    adder = item.ToLower().Split(new string[] { " as " }, StringSplitOptions.None)[1].Trim();
                }
                else
                {
                    adder = item.Trim();
                }
                if (adder.Contains('.'))
                {
                    adder = adder.Split('.')[1];
                }
                fields.Add(adder);
            }

            this.cmd.CommandText = sql;
            Result r = new Result(this.cmd.CommandText);
            if (this.connection.State != System.Data.ConnectionState.Open) this.connection.Open();
            SQLiteDataReader re = this.cmd.ExecuteReader();
            while (re.Read())
            {
                Row row = new Row(re.StepCount);

                foreach (string f in fields)
                {
                    row.AddCell(f, re[f].ToString());
                }

                r.AddRow(row);
            }
            re.Close();
            return r;
        }
開發者ID:WebDaD,項目名稱:Toolkit,代碼行數:42,代碼來源:SQLite.cs

示例2: getRow

        public Result getRow(Joinable j, string[] fields, Condition[] c = null, GroupBy g = null, OrderBy[] o = null, int limit = 0)
        {
            this.cmd.CommandText = "SELECT " + String.Join(",", fields) + " FROM " + j.GetTableName();
            if (c != null)
            {
                this.cmd.CommandText += " WHERE (";
                foreach (Condition item in c)
                {
                    this.cmd.CommandText += item.ToString() + " AND ";
                }
                this.cmd.CommandText = this.cmd.CommandText.Remove(this.cmd.CommandText.Length - 5);
                this.cmd.CommandText += ") ";
            }
            if (g != null)
            {
                this.cmd.CommandText += g.ToString();
            }
            if (o != null)
            {
                this.cmd.CommandText += " ORDER BY ";
                foreach (OrderBy item in o)
                {
                    this.cmd.CommandText += item.ToShortString() + ", ";
                }
                this.cmd.CommandText = this.cmd.CommandText.Remove(this.cmd.CommandText.Length - 2);
            }
            if (limit != 0)
            {
                this.cmd.CommandText += " LIMIT " + limit.ToString();
            }
            Result r = new Result(this.cmd.CommandText);
            if (this.connection.State != System.Data.ConnectionState.Open) this.connection.Open();
            SQLiteDataReader re = this.cmd.ExecuteReader();
            while (re.Read())
            {
                Row row = new Row(re.StepCount);

                foreach (string f in fields)
                {
                    row.AddCell(f, re[f].ToString());
                }

                r.AddRow(row);
            }
            re.Close();
            return r;
        }
開發者ID:WebDaD,項目名稱:Toolkit,代碼行數:47,代碼來源:SQLite.cs

示例3: Join

        /// <summary>
        /// Get a Join on TWO tables.
        /// </summary>
        /// <param name="tables"></param>
        /// <param name="c"></param>
        /// <param name="g"></param>
        /// <param name="o"></param>
        /// <returns></returns>
        public Result Join(Joinable[] tables, Condition[] c, GroupBy g, OrderBy[] o)
        {
            string sql = "SELECT ";
            List<string> fields = new List<string>();
            foreach (Joinable j in tables)
            {
                sql += String.Join(",", j.GetFields(true)) + ", ";
                foreach (string item in j.GetFields(true))
                {
                    fields.Add(item);
                }
            }
            sql = sql.Remove(sql.Length - 2);
            sql += " FROM ";
            foreach (Joinable j in tables)
            {
                sql += j.GetTableName() + ", ";
            }
            sql = sql.Remove(sql.Length - 2);
            sql += " WHERE (";
            sql += tables[0].GetJoinOn(tables[1]) + "=" + tables[1].GetJoinOn(tables[0]); //TODO: make this work for more tables...
            sql += ") ";
            if (c != null)
            {
                sql += " AND (";
                foreach (Condition item in c)
                {
                    sql += item.ToString() + " AND ";
                }
                sql = sql.Remove(sql.Length - 5);
                sql += ") ";
            }
            if (g != null)
            {
                sql += g.ToString();
            }
            if (o != null)
            {
                sql += " ORDER BY ";
                foreach (OrderBy item in o)
                {
                    sql += item.ToShortString() + ", ";
                }
                sql = sql.Remove(sql.Length - 2);
            }
            this.cmd.CommandText = sql;
            Result r = new Result(this.cmd.CommandText);
            if (this.connection.State != System.Data.ConnectionState.Open) this.connection.Open();
            SQLiteDataReader re = this.cmd.ExecuteReader();
            while (re.Read())
            {
                Row row = new Row(re.StepCount);

                foreach (string f in fields)
                {
                    row.AddCell(f, re[f].ToString());
                }

                r.AddRow(row);
            }
            re.Close();
            return r;
        }
開發者ID:WebDaD,項目名稱:Toolkit,代碼行數:71,代碼來源:SQLite.cs


注:本文中的System.Result.AddRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。