コード例 #1
0
        //Arama Yapısından Sık Kullanılan İç Sorgular İçin Eklendi
        public static SqlQuery ToInnerQuery(this SqlQuery query, string alias)
        {
            if (null != query)
            {
                if (String.IsNullOrEmpty(alias))
                    alias = "T";

                SqlQuery inner = new SqlQuery();
                inner.Text.Append("SELECT * FROM (");
                inner.Combine(query);
                inner.Text.Append(") ");
                inner.Text.Append(alias);
                return inner;
            }
            return null;
        }
コード例 #2
0
            public SqlQuery ToQuery()
            {
                if (null != this.query)
                    return this.query;

                SqlQuery query = new SqlQuery();
                if (null != this.Table)
                {
                    query.Text.Append(this.Table.Alias);
                    query.Text.Append('.');
                }
                query.Combine(this.Criteria.ToQuery());
                return query;
            }
コード例 #3
0
ファイル: SelectSql.cs プロジェクト: ionixNet/ionix.UI
 public SqlQuery ToQuery()
 {
     SqlQuery query = new SqlQuery();
     StringBuilder text = query.Text;
     bool justWhereSql = this.columns.Count == 0 || this.tables.Count == 0;
     if (!justWhereSql)
     {
         text.Append("SELECT ");
         foreach (SelectSql.ColumnItem clmn in this.columns)
         {
             text.Append(clmn); text.Append(", ");
         }
         foreach (string sqlColumn in this.customColumnSql)
         {
             text.Append(sqlColumn); text.Append(", ");
         }
         text.Remove(text.Length - 2, 2);
         text.Append(" FROM ");
         text.Append(this.GetLeftTable());
         text.AppendLine();
         foreach (SelectSql.JoinItem item in this.joins)
         {
             text.Append(item);
             text.AppendLine();
         }
     }
     if (this.custom.Text.Length != 0)
     {
         query.Combine(this.custom);
     }
     if (this.wheres.Count > 0)
     {
         if (justWhereSql)
             text.AppendLine();
         text.Append("WHERE ");
         foreach (SelectSql.WhereItem item in this.wheres)
         {
             query.Combine(item.ToQuery());
             query.Text.Append(" AND ");
         }
         query.Text.Remove(query.Text.Length - 5, 5);
     }
     return query;
 }