Ejemplo n.º 1
0
        /// <summary>
        /// Performs a deep copy of the current instance.
        /// </summary>
        /// <returns>a <see cref="SelectQuery"/> instance that is a deep copy of the current instance.</returns>
        public SelectQuery Clone()
        {
            SelectQuery query = new(Columns.Select(x => x.Clone()).ToArray())
            {
                Alias          = Alias,
                Columns        = Columns.Select(x => x.Clone()).ToList(),
                HavingCriteria = HavingCriteria?.Clone(),
                WhereCriteria  = WhereCriteria?.Clone(),
                PageIndex      = PageIndex,
                PageSize       = PageSize
            };

            query.From(Tables.Select(t => t.Clone()).ToArray());

            foreach (IUnionQuery <SelectQuery> item in Unions)
            {
                query.Union(item.Build().Clone());
            }

            foreach (IOrder item in Sorts)
            {
                query.OrderBy(item);
            }

            return(query);
        }

        ///<inheritdoc/>
        ITable ITable.Clone() => Clone();

        ///<inheritdoc/>
        IColumn IColumn.Clone() => Clone();
Ejemplo n.º 2
0
 public QueryCriteria Concat(QueryCriteria queryCriteria)
 {
     if (queryCriteria == null)
     {
         return(this);
     }
     Dictinct = queryCriteria.Dictinct;
     SelectCriteria.AddRange(queryCriteria.SelectCriteria);
     JoinCriteria.AddRange(queryCriteria.JoinCriteria);
     WhereCriteria.AddRange(queryCriteria.WhereCriteria);
     InternalWhere.AddRange(queryCriteria.InternalWhere);
     OrderCriteria.AddRange(queryCriteria.OrderCriteria);
     return(this);
 }
Ejemplo n.º 3
0
        ///<inheritdoc/>
        public bool Equals(SelectQuery other)
        {
            bool equals = false;

            if (other != null && other.PageSize == PageSize && other.PageIndex == PageIndex && other.Alias == Alias)
            {
                equals = Columns.SequenceEqual(other.Columns) &&
                         ((WhereCriteria == null && other.WhereCriteria == null) || WhereCriteria.Equals(other.WhereCriteria)) &&
                         Tables.SequenceEqual(other.Tables) &&
                         Unions.SequenceEqual(other.Unions) &&
                         Sorts.SequenceEqual(other?.Sorts);
            }

            return(equals);
        }
Ejemplo n.º 4
0
 public QueryParams Join(QueryParams queryParams)
 {
     if (queryParams == null)
     {
         return(this);
     }
     Dictinct = queryParams.Dictinct;
     TakeRows = queryParams.TakeRows;
     SkipRows = queryParams.SkipRows;
     InternalWhere.AddRange(queryParams.InternalWhere);
     WhereCriteria.AddRange(queryParams.WhereCriteria);
     JoinCriteria.AddRange(queryParams.JoinCriteria);
     OrderCriteria.AddRange(queryParams.OrderCriteria);
     return(this);
 }
Ejemplo n.º 5
0
 public QueryCriteria Join(QueryParams queryParams)
 {
     if (queryParams == null)
     {
         return(this);
     }
     Dictinct = queryParams.Dictinct;
     TakeRows = queryParams.TakeRows;
     SkipRows = queryParams.SkipRows;
     WhereCriteria.AddRange(queryParams.WhereCriteria);
     InternalWhere.AddRange(queryParams.InternalWhere);
     JoinCriteria.AddRange(queryParams.JoinCriteria);
     if (queryParams.OrderCriteria.Count > 0)
     {
         OrderCriteria = queryParams.OrderCriteria;             // overwrite default view ordering
     }
     return(this);
 }
Ejemplo n.º 6
0
        public void WhereQuery()
        {
            string[] companies = { "Consolidated Messenger", "Alpine Ski House",     "Southridge Video",         "City Power & Light",
                                   "Coho Winery",            "Wide World Importers", "Graphic Design Institute", "Adventure Works",
                                   "Humongous Insurance",    "Woodgrove Bank",       "Margie's Travel",          "Northwind Traders",
                                   "Blue Yonder Airlines",   "Trey Research",        "The Phone Company",
                                   "Wingtip Toys",           "Lucerne Publishing",   "Fourth Coffee" };

            IQueryable <string> queryableData = companies.AsQueryable <string>();

            var filter = new Dictionary <string, object>();

            filter.Add("", "Fourth Coffee");

            var whereCriteria = new WhereCriteria <string>(new CriteriaParameters()
            {
                SingleProperty = filter
            });
            var builder = new CriteriaBuilder <string>(whereCriteria);

            var result = builder.Materialize(builder.Build(queryableData));

            Assert.AreEqual("Fourth Coffee", "Fourth Coffee");
        }
Ejemplo n.º 7
0
        public FluentQuery Where(params Tuple <string, object, FilterTerm.Operator>[] criteria)
        {
            WhereCriteria.AddRange(criteria);

            return(this);
        }