private async Task <KeyValuePair <string, double> > CaculateOperandAsync(Operand operand, VariableSet variableSet)
        {
            Console.WriteLine("Break at: " + operand.Name + operand.Expression);
            foreach (var item in variableSet)
            {
                Console.WriteLine(item.VariableName + item.Value);
            }
            KeyValuePair <string, double> result = new KeyValuePair <string, double>();

            if (operand.Type == (int)OperandTypeValue.EXPRESSION || operand.Type == (int)OperandTypeValue.GROUP_VALUE)
            {
                var    ep = new ExpressionParser();
                var    compiledExpression = ep.Parse(operand.Expression);
                var    resultStack        = compiledExpression.Evaluate(variableSet);
                double value = Convert.ToDouble(resultStack.Pop().GetValue());
                if (operand.Type == (int)OperandTypeValue.EXPRESSION)
                {
                    operand.Value = value;
                    result        = new KeyValuePair <string, double>(operand.Name, operand.Value);
                }
                else if (operand.Type == (int)OperandTypeValue.GROUP_VALUE)
                {
                    await _context.Entry(operand).Collection(x => x.GroupValues).LoadAsync();

                    var gropValues = operand.GroupValues.Where(x => x.Max > value).OrderBy(c => c.Max).ToList();
                    if (gropValues.Count() != 0)
                    {
                        compiledExpression = ep.Parse(gropValues[0].Value);
                        resultStack        = compiledExpression.Evaluate(variableSet);
                        value = Convert.ToDouble(resultStack.Pop().GetValue());
                        Console.WriteLine("Add: " + operand.Name);
                        result = new KeyValuePair <string, double>(operand.Name, value);
                    }
                }
            }
            else if (operand.Type == (int)OperandTypeValue.STATIC)
            {
                result = new KeyValuePair <string, double>(operand.Name, operand.Value);
            }
            return(result);
        }
        private async Task <VariableSet> GetOperandChildsAsync(Operand parent, VariableSet variableSet)
        {
            KeyValuePair <string, double> result;
            await _context.Entry(parent).Collection(x => x.Childs).Query().LoadAsync();

            var childs = parent.Childs;

            if (childs.Count > 1)
            {
                //caculate child
                for (int i = 1; i < childs.Count; i++)
                {
                    Console.WriteLine("i: " + i);
                    await GetOperandChildsAsync(childs.ElementAt(i), variableSet);
                }
                //caculate parent
                result = await CaculateOperandAsync(parent, variableSet);

                Console.WriteLine(result.Key + " " + result.Value);
                if (variableSet.Where(x => x.VariableName.Equals(result.Key)).FirstOrDefault() == null)
                {
                    variableSet.RegisterVariable(OperandType.Double, result.Key, result.Value);
                }
                return(variableSet);
            }
            else
            {
                result = await CaculateOperandAsync(parent, variableSet);

                Console.WriteLine(result.Key + " " + result.Value);
                if (variableSet.Where(x => x.VariableName.Equals(result.Key)).FirstOrDefault() == null)
                {
                    variableSet.RegisterVariable(OperandType.Double, result.Key, result.Value);
                }
            }
            return(variableSet);
        }