public override object InternalExecute(Program program)
        {
            AggregateTable table = new AggregateTable(this, program);

            try
            {
                table.Open();
                return(table);
            }
            catch
            {
                table.Dispose();
                throw;
            }
        }
Exemple #2
0
    public static Aggregate GetOrCreate(Type aggregateType, string aggregateId)
    {
        string         modelName = ModelNameGetter.GetModelName(aggregateType);
        Aggregate      aggregate;
        AggregateTable table = GetTable(modelName);

        try{
            aggregate = table.GetAggregate(aggregateId);
        }
        catch (KeyNotFoundException k) {
            ConstructorInfo cInfo = aggregateType.GetConstructor(Type.EmptyTypes);
            aggregate = (Aggregate)cInfo.Invoke(Type.EmptyTypes);
            table.InsertAggregate(aggregateId, aggregate);
        }
        return(aggregate);
    }
Exemple #3
0
        public static Value Aggregate(IList <Value> parameters)
        {
            var validate = Expression.ValidateHelper("Aggregate", parameters, 2, new List <ValueType>()
            {
                ValueType.Object, ValueType.Object
            });

            if (validate != null)
            {
                return(validate);
            }

            if (!(parameters[0].Object is SimpleTable))
            {
                return(Value.CreateErrorValue("Aggregate() parameter #1 is not a table"));
            }
            else if (!(parameters[1].Object is SimpleTable))
            {
                return(Value.CreateErrorValue("Aggregate() parameter #2 is not a table"));
            }

            var sourceTable = parameters[0].Object as SimpleTable;
            var mapTable    = parameters[1].Object as SimpleTable;

            try
            {
                var result = AggregateTable.Execute(sourceTable, mapTable);

                if (result.HasError)
                {
                    return(Value.CreateErrorValue(result.ErrorMessage, result.Exception));
                }

                return(new Value(result.Result));
            }
            catch (System.Exception e)
            {
                return(Value.CreateErrorValue("Aggregate() unable to expand table: " + e.ToString(), e));
            }
        }