/// <summary>
        /// Builds a <see langword="string"/> representing the <see cref="Expression"/>.
        /// </summary>
        /// <param name="builder">A <see cref="System.Text.StringBuilder"/> to add the created <see langword="string"/>.</param>
        internal override void BuildString(StringBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            const int num = 0;
            SerializableExpression expression = Object;

            if (expression != null)
            {
                expression.BuildString(builder);
                builder.Append(".");
            }
            builder.Append(Method.Name);
            builder.Append("(");
            int num2  = num;
            int count = Arguments.Count;

            while (num2 < count)
            {
                if (num2 > num)
                {
                    builder.Append(", ");
                }
                Arguments[num2].BuildString(builder);
                num2++;
            }
            builder.Append(")");
        }
        /// <summary>
        /// Extension method for <see cref="SerializableExpression"/>.
        /// Returns <see cref="Expression"/>.
        /// </summary>
        /// <param name="exp">Serializable expression to convert</param>
        /// <returns>Returns <see cref="Expression"/>.</returns>
        public static Expression Deserialize(this SerializableExpression exp)
        {
            // http://interlinq.codeplex.com/discussions/60896
            var fakeHandler = new ClientQueryHandler();
            var visitor     = new SerializableExpressionConverter(exp, fakeHandler);

            return(visitor.Visit(exp));
        }
 /// <summary>
 /// Extension Method for <see cref="IEnumerable"/>.
 /// Returns the result of the executed <see cref="SerializableExpression"/>.
 /// </summary>
 /// <param name="exp">Extended class instance.</param>
 /// <param name="linqHandler"><see cref="IQueryHandler"/>.</param>
 /// <returns>Returns the result of the executed <see cref="SerializableExpression"/>.</returns>
 public static object Convert(this SerializableExpression exp, IQueryHandler linqHandler)
 {
     return(new SerializableExpressionConverter(exp, linqHandler).Visit());
 }
예제 #4
0
 /// <summary>
 /// Retrieves data from the server by an <see cref="SerializableExpression">Expression</see> tree.
 /// </summary>
 /// <remarks>
 /// This method's return type depends on the submitted 
 /// <see cref="SerializableExpression">Expression</see> tree.
 /// Here some examples ('T' is the requested type):
 /// <list type="list">
 ///     <listheader>
 ///         <term>Method</term>
 ///         <description>Return Type</description>
 ///     </listheader>
 ///     <item>
 ///         <term>Select(...)</term>
 ///         <description>T[]</description>
 ///     </item>
 ///     <item>
 ///         <term>First(...), Last(...)</term>
 ///         <description>T</description>
 ///     </item>
 ///     <item>
 ///         <term>Count(...)</term>
 ///         <description><see langword="int"/></description>
 ///     </item>
 ///     <item>
 ///         <term>Contains(...)</term>
 ///         <description><see langword="bool"/></description>
 ///     </item>
 /// </list>
 /// </remarks>
 /// <param name="expression">
 ///     <see cref="SerializableExpression">Expression</see> tree 
 ///     containing selection and projection.
 /// </param>
 /// <returns>Returns requested data.</returns>
 /// <seealso cref="IQueryRemoteHandler.Retrieve"/>
 public object Retrieve(SerializableExpression expression)
 {
     return InnerHandler.Retrieve(expression);
 }
예제 #5
0
 /// <summary>
 /// Retrieves data from the server by an <see cref="SerializableExpression">Expression</see> tree.
 /// </summary>
 /// <remarks>
 /// This method's return type depends on the submitted 
 /// <see cref="SerializableExpression">Expression</see> tree.
 /// Here some examples ('T' is the requested type):
 /// <list type="list">
 ///     <listheader>
 ///         <term>Method</term>
 ///         <description>Return Type</description>
 ///     </listheader>
 ///     <item>
 ///         <term>Select(...)</term>
 ///         <description>T[]</description>
 ///     </item>
 ///     <item>
 ///         <term>First(...), Last(...)</term>
 ///         <description>T</description>
 ///     </item>
 ///     <item>
 ///         <term>Count(...)</term>
 ///         <description><see langword="int"/></description>
 ///     </item>
 ///     <item>
 ///         <term>Contains(...)</term>
 ///         <description><see langword="bool"/></description>
 ///     </item>
 /// </list>
 /// </remarks>
 /// <param name="expression">
 ///     <see cref="SerializableExpression">Expression</see> tree 
 ///     containing selection and projection.
 /// </param>
 /// <returns>Returns requested data.</returns>
 /// <seealso cref="IQueryRemoteHandler.Retrieve"/>
 public object Retrieve(SerializableExpression expression)
 {
     try
     {
         return Handler.Retrieve(expression);
     }
     catch (FaultException ex)
     {
         Console.WriteLine("Test Failed on server.");
         handler = null;
         throw new Exception("The execution of the query failed on the server. See inner exception for more details.", ex);
     }
     catch (Exception)
     {
         Console.WriteLine("Test Failed.");
         handler = null;
         throw;
     }
 }