Beispiel #1
0
 /// <summary>
 /// The base query object from which new queries using "where" criteria will be constructed.
 /// </summary>
 public ISqlQuery Query(QueryType type)
 {
     if (_Query != null)
     {
         return _Query.Clone(type);
     }
     else
     {
         var query = new SqlQuery(type);
         query.From = TableName;
         query.Select = SelectAll ? "*" : String.Join(",", FieldNames);
         return query;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Returns a deep copy of this object
        /// </summary>
        /// <returns></returns>
        public ISqlQuery Clone(QueryType type)
        {
            SqlQuery newQuery = new SqlQuery();

            newQuery.QueryType = type;
            newQuery.TableName = TableName;
            newQuery.Select = Select;
            newQuery.From = From;
            newQuery.GroupBy = GroupBy;
            newQuery.Having = Having;
            newQuery.OptimizeParameterNames = OptimizeParameterNames;

            if (_sortCriterionList.IsValueCreated)
            {
                foreach (SortCriterion item in sortCriterionList)
                {
                    var clone = item.Clone();
                    clone.Owner = newQuery;
                    newQuery.sortCriterionList.Add(clone);
                }
            }
            if (_whereClause != null)
            {
                newQuery.whereClause = whereClause.Clone();
            }
            if (_sqlFieldMap.IsValueCreated)
            {
                newQuery.AddFieldMap(sqlFieldMap);
            }
            if (parameterList != null)
            {
                foreach (IDataParameter parm in Parameters)
                {
                    newQuery.AddParameter(parm);
                }
            }
            newQuery.Clean();
            return newQuery;
        }