private void ApplyJoinCondition(SerializableJoin join, QueryCondition sourceCondition)
 {
     join.Conditions = new List <SerializableCondition>();
     foreach (QueryCondition conditionItem in sourceCondition)
     {
         var condition = new SerializableCondition()
         {
             ConditionType    = conditionItem.ConditionType,
             IsNot            = conditionItem.IsNot,
             LogicalOperation = conditionItem.LogicalOperation
         };
         condition.LeftExpression   = MapLeftExpression(conditionItem.LeftExpression);
         condition.RightExpressions = MapRightExpression(conditionItem.RightExpressions);
         join.Conditions.Add(condition);
     }
 }
        private List <SerializableCondition> MapConditionItems(IEnumerable <QueryCondition> sourceQueryCondition,
                                                               List <SerializableCondition> serializableConditions = null)
        {
            var items = serializableConditions ?? new List <SerializableCondition>();

            foreach (QueryCondition conditionItem in sourceQueryCondition)
            {
                var condition = new SerializableCondition()
                {
                    ConditionType    = conditionItem.ConditionType,
                    IsNot            = conditionItem.IsNot,
                    LogicalOperation = conditionItem.LogicalOperation
                };
                if ((conditionItem.ConditionType == QueryConditionType.Block ||
                     conditionItem.ConditionType == QueryConditionType.Blank) &&
                    conditionItem.Any())
                {
                    condition.Items = MapConditionItems(conditionItem, condition.Items);
                }
                if (conditionItem.ConditionType == QueryConditionType.Exist)
                {
                    var sourceExpressions = conditionItem.RightExpressions;
                    var targetExpressions = new List <SerializableExpression>();
                    foreach (QueryColumnExpression sourceExpression in sourceExpressions)
                    {
                        var targetExpression = new SerializableExpression();
                        var serializedQuery  = ConvertToSerializableQuery(sourceExpression.SubSelect);
                        targetExpression.ExpressionType = sourceExpression.ExpressionType;
                        targetExpression.SubSelect      = serializedQuery;
                        targetExpressions.Add(targetExpression);
                    }
                    condition.RightExpressions = targetExpressions;
                }
                else
                {
                    condition.LeftExpression   = MapLeftExpression(conditionItem.LeftExpression);
                    condition.RightExpressions = MapRightExpression(conditionItem.RightExpressions);
                }
                items.Add(condition);
            }
            return(items);
        }