当前位置: 首页>>代码示例>>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;未经允许,请勿转载。