示例#1
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            var candidate = values[AttributeName];

            if (candidate is OID)
            {
                var candidateOid = (OID)candidate;
                candidate = _query.GetQueryEngine().GetObjectFromOid(candidateOid);
            }

            var l = ((IEnumerable)candidate).Cast<object>().ToList();
            var localFromIndex = _fromIndex;
            var localEndIndex = _fromIndex + _size;

            // If not throw exception, we must implement 
            // Index Out Of Bound protection
            if (!_throwExceptionIfOutOfBound)
            {
                // Check from index
                if (localFromIndex > l.Count - 1)
                    localFromIndex = 0;

                // Check end index
                if (localEndIndex > l.Count)
                    localEndIndex = l.Count;
            }

            _sublist = new LazySimpleListOfAoi<object>(GetInstanceBuilder(), ReturnInstance());
            var count = localEndIndex - localFromIndex;
            var sublist = l.GetRange(localFromIndex, count);

            _sublist.AddAll(sublist);
        }
示例#2
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            var candidate = values[AttributeName];

            if (candidate is OID)
            {
                var candidateOid = (OID)candidate;
                candidate = _query.GetQueryEngine().GetObjectFromOid(candidateOid);
            }

            if (!(candidate is IList || candidate is string))
                throw new OdbRuntimeException(
                    NDatabaseError.UnsupportedOperation.AddParameter("Size() with string or collection as the argument"));

            var candidateAsString = candidate as string;
            if (candidateAsString != null)
            {
                _size = candidateAsString.Length;
            }
            else
            {
                var list = (IList)candidate;
                _size = list.Count;    
            }
        }
示例#3
0
        public override AttributeValuesMap GetValues()
        {
            var map = new AttributeValuesMap();

            foreach (var constraint in Constraints)
                map.PutAll(((IInternalConstraint)constraint).GetValues());

            return map;
        }
示例#4
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            var number = Convert.ToDecimal(values[AttributeName]);
            var bd = ValuesUtil.Convert(number);
            if (bd.CompareTo(_maxValue) <= 0)
                return;

            _oidOfMaxValues = oid;
            _maxValue = bd;
        }
示例#5
0
        public AttributeValuesMap GetValues()
        {
            var map = new AttributeValuesMap();

            if (_oid != null)
                map.SetOid(_oid);
            else
                map.Add(AttributeName, TheObject);

            return map;
        }
示例#6
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            _value = values[AttributeName];
            if (!(_value is ICollection || IsGenericCollection(_value.GetType())))
                return;

            // For collection,we encapsulate it in an lazy load list that will create objects on demand
            var c = ((IEnumerable) _value).Cast<object>().ToList();
            var l = new LazySimpleListOfAoi<object>(GetInstanceBuilder(), ReturnInstance());
            l.AddRange(c);
            _value = l;
        }
        protected override bool MatchObjectWithOid(OID oid, bool returnObject, bool inMemory)
        {
            CurrentOid = oid;

            // Gets a map with the values with the fields involved in the query
            _values = ObjectReader.ReadObjectInfoValuesFromOID(ClassInfo, CurrentOid, true, _involvedFields,
                                                               _involvedFields, 0);

            var objectMatches = true;
            if (!_sodaQuery.IsForSingleOid())
            {
                // Then apply the query on the field values
                objectMatches = _sodaQuery.Match(_values);
            }

            var objectInfoHeader = _values.GetObjectInfoHeader();
            // Stores the next position
            NextOID = objectInfoHeader.GetNextObjectOID();
            return objectMatches;
        }
示例#8
0
        internal static IOdbComparable BuildIndexKey(string indexName, AttributeValuesMap values, IList<string> fields)
        {
            if (fields.Count == 1)
                return new SimpleCompareKey(values.GetComparable(fields[0]));

            var keys = new IOdbComparable[fields.Count];
            for (var i = 0; i < fields.Count; i++)
            {
                try
                {
                    var @object = (IComparable) values[fields[i]];
                    keys[i] = new SimpleCompareKey(@object);
                }
                catch (Exception)
                {
                    throw new OdbRuntimeException(
                        NDatabaseError.IndexKeysMustImplementComparable.AddParameter(indexName).AddParameter(fields[i]).
                            AddParameter(values[fields[i]].GetType().FullName));
                }
            }

            return new ComposedCompareKey(keys);
        }
示例#9
0
 public override void Execute(OID oid, AttributeValuesMap values)
 {
     _count = Decimal.Add(_count, One);
 }
 public abstract void Execute(OID oid, AttributeValuesMap values);
示例#11
0
 public override void Execute(OID oid, AttributeValuesMap values)
 {
     var number = Convert.ToDecimal(values[AttributeName]);
     _sum = Decimal.Add(_sum, ValuesUtil.Convert(number));
 }
示例#12
0
 public override void Execute(OID oid, AttributeValuesMap values)
 {
     var n = Convert.ToDecimal(values[AttributeName]);
     _totalValue = Decimal.Add(_totalValue, ValuesUtil.Convert(n));
     _nbValues++;
 }