Пример #1
0
        public ICriteria SetProjection(IProjection projection)
        {
            ICriteriaEvent criteriaEvent = new SetProjectionEvent(projection);

            foreach (IShard shard in shards)
            {
                if (shardToCriteriaMap[shard] != null)
                {
                    shardToCriteriaMap[shard].SetProjection(projection);
                }
                else
                {
                    shardToEventListMap[shard].Add(criteriaEvent);
                }
            }
            return(this);
        }
Пример #2
0
        private void SetAvgProjection(IProjection projection)
        {
            // We need to modify the query to pull back not just the average but also
            // the count.  We'll do this by creating a ProjectionList with both the
            // average and the row count.
            ProjectionList projectionList = Projections.ProjectionList();

            projectionList.Add(projection);
            projectionList.Add(Projections.RowCount());
            ICriteriaEvent criteriaEvent = new SetProjectionEvent(projectionList);

            foreach (IShard shard in shards)
            {
                if (shard.GetCriteriaById(criteriaId) != null)
                {
                    shard.GetCriteriaById(criteriaId).SetProjection(projectionList);
                }
                else
                {
                    shard.AddCriteriaEvent(criteriaId, criteriaEvent);
                }
            }
        }