Commits

Jacob Reimers  committed d611034

Enforced code styles.

  • Participants
  • Parent commits a413a6c

Comments (0)

Files changed (24)

File Linq2Rest.MvcSite/Linq2Rest.MvcSite.csproj

       </FlavorProperties>
     </VisualStudio>
   </ProjectExtensions>
-  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
 </Project>

File Linq2Rest.Reactive.SL.IntegrationTests.Web/ClientBin/Linq2Rest.Reactive.SL.IntegrationTests.xap

Binary file modified.

File Linq2Rest.Reactive.SL.IntegrationTests/Linq2Rest.Reactive.SL.IntegrationTests.csproj

     <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight">
       <HintPath>$(MSBuildExtensionsPath)\..\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Testing\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
     </Reference>
+    <Reference Include="System.Reactive.Core">
+      <HintPath>..\packages\Rx-Core.2.0.20304-beta\lib\SL5\System.Reactive.Core.dll</HintPath>
+    </Reference>
     <Reference Include="System.Reactive.Interfaces">
       <HintPath>..\packages\Rx-Interfaces.2.0.20304-beta\lib\SL5\System.Reactive.Interfaces.dll</HintPath>
     </Reference>

File Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.csproj

     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

File Linq2Rest.Reactive.Tests/Properties/AssemblyInfo.cs

-using System.Reflection;
+using System.Diagnostics.Contracts;
+using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

File Linq2Rest.Reactive.WP7Sample/App.xaml.cs

-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
 
 namespace Linq2Rest.Reactive.WP7Sample
 {
+	using System.Windows;
+	using System.Windows.Navigation;
+	using Microsoft.Phone.Controls;
+	using Microsoft.Phone.Shell;
+
 	public partial class App : Application
 	{
 		/// <summary>

File Linq2Rest.Reactive.WP7Sample/PhoneSerializerFactory.cs

+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
+
 namespace Linq2Rest.Reactive.WP7Sample
 {
 	using System.Collections.Generic;

File Linq2Rest.Reactive/Linq2Rest.Reactive.csproj

     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

File Linq2Rest.Tests/FakeChildItem.cs

+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
+
+namespace Linq2Rest.Tests
+{
+	using System.Collections.Generic;
+	using System.Collections.ObjectModel;
+	using System.Runtime.Serialization;
+
+	[DataContract]
+	public class FakeChildItem
+	{
+		private readonly Collection<FakeGrandChildItem> _children = new Collection<FakeGrandChildItem>();
+
+		public int ID { get; set; }
+
+		public string ChildStringValue { get; set; }
+
+		public ICollection<FakeGrandChildItem> Children
+		{
+			get { return _children; }
+		}
+	}
+}

File Linq2Rest.Tests/FakeGrandChildItem.cs

+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
+
+namespace Linq2Rest.Tests
+{
+	using System.Runtime.Serialization;
+
+	[DataContract]
+	public class FakeGrandChildItem
+	{
+		public string GrandChildStringValue { get; set; }
+	}
+}

File Linq2Rest.Tests/FakeItem.cs

 // Please see http://www.opensource.org/licenses/MS-PL] for details.
 // All other rights reserved.
 
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-
 namespace Linq2Rest.Tests
 {
 	using System;
+	using System.Collections.Generic;
+	using System.Collections.ObjectModel;
 	using System.Runtime.Serialization;
 	using System.Xml.Serialization;
 
 	[DataContract]
 	public class FakeItem
 	{
-        public int ID { get; set; }
-
+		private readonly Collection<FakeChildItem> _children = new Collection<FakeChildItem>();
 		[DataMember(Name = "Text")]
 		private string _stringValue;
 
+		public int ID { get; set; }
+
 		[XmlElement(ElementName = "Number")]
 		public int IntValue { get; set; }
 
 		[DataMember(Name = "Choice")]
 		public Choice ChoiceValue { get; set; }
 
-        private readonly Collection<FakeChildItem> children = new Collection<FakeChildItem>();
-
-        public ICollection<FakeChildItem> Children{
-            get { return children; }
-        }
+		public ICollection<FakeChildItem> Children
+		{
+			get { return _children; }
+		}
 	}
-
-    [DataContract]
-    public class FakeChildItem {
-        public int ID { get; set; }
-
-        public string ChildStringValue { get; set; }
-
-        private readonly Collection<FakeGrandChildItem> children = new Collection<FakeGrandChildItem>();
-
-        public ICollection<FakeGrandChildItem> Children {
-            get { return children; }
-        }
-    }
-
-    [DataContract]
-    public class FakeGrandChildItem {
-        public string GrandChildStringValue { get; set; }
-    }
 }

File Linq2Rest.Tests/Fakes/InMemoryJsonRestClient.cs

-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.Serialization.Json;
-using System.Text;
-using System.Web;
-using Linq2Rest.Parser;
-using Linq2Rest.Provider;
+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
 
-namespace Linq2Rest.Tests.Fakes {
-    public class InMemoryJsonRestClient<T> : IRestClient {
-        private readonly IEnumerable<T> data;
-        private DataContractJsonSerializer serializer;
+namespace Linq2Rest.Tests.Fakes
+{
+	using System;
+	using System.Collections.Generic;
+	using System.IO;
+	using System.Linq;
+	using System.Runtime.Serialization.Json;
+	using System.Text;
+	using System.Web;
+	using Linq2Rest.Provider;
 
-        public InMemoryJsonRestClient(IEnumerable<T> data, IEnumerable<Type> knownTypes) {
-            this.data = data;
-            serializer = new DataContractJsonSerializer(typeof (T), knownTypes);
-        }
+	public class InMemoryJsonRestClient<T> : IRestClient
+	{
+		private readonly IEnumerable<T> _data;
+		private readonly DataContractJsonSerializer _serializer;
 
-        public void Dispose() {
-            
-        }
+		public InMemoryJsonRestClient(IEnumerable<T> data, IEnumerable<Type> knownTypes)
+		{
+			_data = data;
+			_serializer = new DataContractJsonSerializer(typeof(T), knownTypes);
+		}
 
-        public Uri ServiceBase {
-            get { return new Uri("http://localhost/InMemoryClient/"); }
-        }
+		public Uri ServiceBase
+		{
+			get { return new Uri("http://localhost/InMemoryClient/"); }
+		}
 
-        public string Get(Uri uri) {
-            string content;
-            using (var stream = new MemoryStream()) {
-                serializer.WriteObject(stream, data.Filter(HttpUtility.ParseQueryString(uri.Query)).ToArray());
-                stream.Seek(0, SeekOrigin.Begin);
-                content = Encoding.Default.GetString(stream.ToArray());
-            }
-            return content;
-        }
-    }
+		public void Dispose()
+		{
+		}
+
+		public string Get(Uri uri)
+		{
+			string content;
+			using (var stream = new MemoryStream())
+			{
+				_serializer.WriteObject(stream, _data.Filter(HttpUtility.ParseQueryString(uri.Query)).ToArray());
+				stream.Seek(0, SeekOrigin.Begin);
+				content = Encoding.Default.GetString(stream.ToArray());
+			}
+
+			return content;
+		}
+	}
 }

File Linq2Rest.Tests/Linq2Rest.Tests.csproj

   </ItemGroup>
   <ItemGroup>
     <Compile Include="Choice.cs" />
+    <Compile Include="FakeChildItem.cs" />
+    <Compile Include="FakeGrandChildItem.cs" />
     <Compile Include="Fakes\InMemoryJsonRestClient.cs" />
     <Compile Include="Implementations\JsonDataContractSerializerFactoryTests.cs" />
     <Compile Include="Implementations\SimpleContractItem.cs" />
   </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

File Linq2Rest.Tests/Parser/ParameterParserTests.cs

 		private ParameterParser<FakeItem> _parser;
 
 		private FakeItem[] _items;
-        private FakeItem[] _nestedItems;
+		private FakeItem[] _nestedItems;
 
 		[TestFixtureSetUp]
 		public void TestFixtureSetup()
 					new FakeItem { IntValue = 3, DoubleValue = 3 }
 				};
 
-            _nestedItems = new[]
-				{
-					new FakeItem { IntValue = 2, DoubleValue = 2, 
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "1"},
-                            new FakeChildItem { ChildStringValue = "2"},
-                            new FakeChildItem { ChildStringValue = "3"}
-                        } }, 
-					new FakeItem { IntValue = 1, DoubleValue = 1, 
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "2"},
-                            new FakeChildItem { ChildStringValue = "3"},
-                            new FakeChildItem { ChildStringValue = "4"}
-                        } }, 
-					new FakeItem { IntValue = 3, DoubleValue = 3, 
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "3"},
-                            new FakeChildItem { ChildStringValue = "4"},
-                            new FakeChildItem { ChildStringValue = "5"}
-                        } }, 
-				};
+			_nestedItems = new[]
+			               	{
+			               		new FakeItem
+			               			{
+			               				IntValue = 2,
+			               				DoubleValue = 2,
+			               				Children =
+			               					{
+			               						new FakeChildItem { ChildStringValue = "1" },
+			               						new FakeChildItem { ChildStringValue = "2" },
+			               						new FakeChildItem { ChildStringValue = "3" }
+			               					}
+			               			},
+			               		new FakeItem
+			               			{
+			               				IntValue = 1,
+			               				DoubleValue = 1,
+			               				Children =
+			               					{
+			               						new FakeChildItem { ChildStringValue = "2" },
+			               						new FakeChildItem { ChildStringValue = "3" },
+			               						new FakeChildItem { ChildStringValue = "4" }
+			               					}
+			               			},
+			               		new FakeItem
+			               			{
+			               				IntValue = 3,
+			               				DoubleValue = 3,
+			               				Children =
+			               					{
+			               						new FakeChildItem { ChildStringValue = "3" },
+			               						new FakeChildItem { ChildStringValue = "4" },
+			               						new FakeChildItem { ChildStringValue = "5" }
+			               					}
+			               			},
+			               	};
 		}
 
 		[Test]
 			Assert.AreEqual(2, filteredItems.Count());
 		}
 
-        [Test]
-        [TestCase(true)]
-        [TestCase(false)]
-        public void WhenRequestContainsAnyFilterParameterThenReturnedModelFilterFilteringCollectionByValue(bool useModelFilter) {
-            var collection = new NameValueCollection { { "$filter", "Children/any(a: a/ChildStringValue eq '1')" } };
-            var filteredItems = GetFilteredItems(useModelFilter, collection, _nestedItems);
+		[Test]
+		[TestCase(true)]
+		[TestCase(false)]
+		public void WhenRequestContainsAnyFilterParameterThenReturnedModelFilterFilteringCollectionByValue(bool useModelFilter)
+		{
+			var collection = new NameValueCollection { { "$filter", "Children/any(a: a/ChildStringValue eq '1')" } };
+			var filteredItems = GetFilteredItems(useModelFilter, collection, _nestedItems);
 
-            Assert.AreEqual(1, filteredItems.Count());
-        }
+			Assert.AreEqual(1, filteredItems.Count());
+		}
 
 		[Test]
 		[TestCase(true)]
 			Assert.AreEqual(1, filteredItems.Count());
 		}
 
-		private object[] GetFilteredItems(bool useModelFilter, NameValueCollection collection) {
-		    return GetFilteredItems(useModelFilter, collection, _items);
+		private object[] GetFilteredItems(bool useModelFilter, NameValueCollection collection)
+		{
+			return GetFilteredItems(useModelFilter, collection, _items);
 		}
 
-        private object[] GetFilteredItems(bool useModelFilter, NameValueCollection collection, FakeItem[] items) {
-            var filteredItems = useModelFilter
-                                    ? GetModelFilter(collection).Filter(items)
-                                    : items.Filter(collection);
-            return filteredItems.ToArray();
-        }
+		private object[] GetFilteredItems(bool useModelFilter, NameValueCollection collection, FakeItem[] items)
+		{
+			var filteredItems = useModelFilter
+									? GetModelFilter(collection).Filter(items)
+									: items.Filter(collection);
+			return filteredItems.ToArray();
+		}
 
 		private IModelFilter<FakeItem> GetModelFilter(NameValueCollection parameters)
 		{

File Linq2Rest.Tests/Provider/CollectionDto.cs

-using System;
-using System.Collections.Generic;
+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
 
-namespace Linq2Rest.Tests.Provider {
-    public class CollectionDto
-    {
-        public int ID { get; set; }
+namespace Linq2Rest.Tests.Provider
+{
+	using System;
+	using System.Collections.Generic;
 
-        public string Content { get; set; }
+	public class CollectionDto
+	{
+		public int ID { get; set; }
 
-        public double Value { get; set; }
+		public string Content { get; set; }
 
-        public DateTime Date { get; set; }
+		public double Value { get; set; }
 
-        public Choice Choice { get; set; }
+		public DateTime Date { get; set; }
 
-        public ICollection<ChildDto> Children { get; set; }
-    }
+		public Choice Choice { get; set; }
+
+		public ICollection<ChildDto> Children { get; set; }
+	}
 }

File Linq2Rest.Tests/Provider/RestContextInMemoryTests.cs

-using System;
-using System.Linq;
-using Linq2Rest.Implementations;
-using Linq2Rest.Provider;
-using Linq2Rest.Tests.Fakes;
-using NUnit.Framework;
+// (c) Copyright Reimers.dk.
+// This source is subject to the Microsoft Public License (Ms-PL).
+// Please see http://www.opensource.org/licenses/MS-PL] for details.
+// All other rights reserved.
 
-namespace Linq2Rest.Tests.Provider {
-    [TestFixture]
-    public class RestContextInMemoryTests {
-        private InMemoryJsonRestClient<FakeItem> _mockClient;
-        private RestContext<FakeItem> _restContext;
+namespace Linq2Rest.Tests.Provider
+{
+	using System.Linq;
+	using Linq2Rest.Implementations;
+	using Linq2Rest.Provider;
+	using Linq2Rest.Tests.Fakes;
+	using NUnit.Framework;
 
-        [SetUp]
-        public void TestSetup() {
-            var knownTypes = new[] {typeof(FakeItem), typeof(FakeChildItem), typeof(FakeGrandChildItem)};
-            ISerializerFactory serializerFactory = new JsonDataContractSerializerFactory(knownTypes);
-            var data = new[]
-				{
-					new FakeItem { StringValue = "2", 
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "1"},
-                            new FakeChildItem { ChildStringValue = "2"},
-                            new FakeChildItem { ChildStringValue = "3"}
-                        } }, 
-					new FakeItem { StringValue = "1",
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "2"},
-                            new FakeChildItem { ChildStringValue = "3"},
-                            new FakeChildItem { ChildStringValue = "4"}
-                        } }, 
-					new FakeItem { StringValue = "3",
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "3"},
-                            new FakeChildItem { ChildStringValue = "4"},
-                            new FakeChildItem { ChildStringValue = "5"}
-                        } }, 
-					new FakeItem { StringValue = "4",
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "6"},
-                            new FakeChildItem { ChildStringValue = "6"},
-                            new FakeChildItem { ChildStringValue = "6"}
-                        } }, 
-					new FakeItem { StringValue = "74",
-                        Children = {
-                            new FakeChildItem { ChildStringValue = "7"},
-                            new FakeChildItem { ChildStringValue = "7"},
-                            new FakeChildItem { ChildStringValue = "7"}
-                        } }, 
-				};
-            _mockClient = new InMemoryJsonRestClient<FakeItem>(data, knownTypes);
-            _restContext = new RestContext<FakeItem>(_mockClient, serializerFactory);
-        }
+	[TestFixture]
+	public class RestContextInMemoryTests
+	{
+		private InMemoryJsonRestClient<FakeItem> _mockClient;
+		private RestContext<FakeItem> _restContext;
 
-        [Test]
-        public void WhenFilteringWithIntegerEqualityThenOnlyMatchingItemsReturned() {
-            var results = _restContext.Query.Where(x => x.StringValue == "2").ToList();
-            Assert.AreEqual(1, results.Count);
-            Assert.AreEqual("2", results.First().StringValue);
-        }
+		[SetUp]
+		public void TestSetup()
+		{
+			var knownTypes = new[] { typeof(FakeItem), typeof(FakeChildItem), typeof(FakeGrandChildItem) };
+			ISerializerFactory serializerFactory = new JsonDataContractSerializerFactory(knownTypes);
+			var data = new[]
+			           	{
+			           		new FakeItem
+			           			{
+			           				StringValue = "2",
+			           				Children =
+			           					{
+			           						new FakeChildItem { ChildStringValue = "1" },
+			           						new FakeChildItem { ChildStringValue = "2" },
+			           						new FakeChildItem { ChildStringValue = "3" }
+			           					}
+			           			},
+			           		new FakeItem
+			           			{
+			           				StringValue = "1",
+			           				Children =
+			           					{
+			           						new FakeChildItem { ChildStringValue = "2" },
+			           						new FakeChildItem { ChildStringValue = "3" },
+			           						new FakeChildItem { ChildStringValue = "4" }
+			           					}
+			           			},
+			           		new FakeItem
+			           			{
+			           				StringValue = "3",
+			           				Children =
+			           					{
+			           						new FakeChildItem { ChildStringValue = "3" },
+			           						new FakeChildItem { ChildStringValue = "4" },
+			           						new FakeChildItem { ChildStringValue = "5" }
+			           					}
+			           			},
+			           		new FakeItem
+			           			{
+			           				StringValue = "4",
+			           				Children =
+			           					{
+			           						new FakeChildItem { ChildStringValue = "6" },
+			           						new FakeChildItem { ChildStringValue = "6" },
+			           						new FakeChildItem { ChildStringValue = "6" }
+			           					}
+			           			},
+			           		new FakeItem
+			           			{
+			           				StringValue = "74",
+			           				Children =
+			           					{
+			           						new FakeChildItem { ChildStringValue = "7" },
+			           						new FakeChildItem { ChildStringValue = "7" },
+			           						new FakeChildItem { ChildStringValue = "7" }
+			           					}
+			           			},
+			           	};
+			_mockClient = new InMemoryJsonRestClient<FakeItem>(data, knownTypes);
+			_restContext = new RestContext<FakeItem>(_mockClient, serializerFactory);
+		}
 
-        [Test]
-        public void WhenFilteringWithAnyUsingEqualityThenOnlyMatchingItemsReturned() {
-            var results = _restContext.Query.Where(x => x.Children.Any(y => y.ChildStringValue == "5")).ToList();
-            Assert.AreEqual(1, results.Count);
-            Assert.AreEqual("3", results.First().StringValue);
-        }
+		[Test]
+		public void WhenFilteringWithIntegerEqualityThenOnlyMatchingItemsReturned()
+		{
+			var results = _restContext.Query.Where(x => x.StringValue == "2").ToList();
+			Assert.AreEqual(1, results.Count);
+			Assert.AreEqual("2", results.First().StringValue);
+		}
 
-        [Test]
-        public void WhenFilteringWithAllUsingEqualityThenOnlyMatchingItemsReturned() {
-            var results = _restContext.Query.Where(x => x.Children.All(y => y.ChildStringValue == "6")).ToList();
-            Assert.AreEqual(1, results.Count);
-            Assert.AreEqual("4", results.First().StringValue);
-        }
+		[Test]
+		public void WhenFilteringWithAnyUsingEqualityThenOnlyMatchingItemsReturned()
+		{
+			var results = _restContext.Query.Where(x => x.Children.Any(y => y.ChildStringValue == "5")).ToList();
+			Assert.AreEqual(1, results.Count);
+			Assert.AreEqual("3", results.First().StringValue);
+		}
 
-        [Test]
-        public void WhenFilteringWithAllUsingEqualityOnFunctionThenOnlyMatchingItemsReturned() {
-            var results = _restContext.Query.Where(x => x.Children.All(y => x.StringValue.StartsWith(y.ChildStringValue))).ToList();
-            Assert.AreEqual(1, results.Count);
-            Assert.AreEqual("74", results.First().StringValue);
-        }
-    }
+		[Test]
+		public void WhenFilteringWithAllUsingEqualityThenOnlyMatchingItemsReturned()
+		{
+			var results = _restContext.Query.Where(x => x.Children.All(y => y.ChildStringValue == "6")).ToList();
+			Assert.AreEqual(1, results.Count);
+			Assert.AreEqual("4", results.First().StringValue);
+		}
+
+		[Test]
+		public void WhenFilteringWithAllUsingEqualityOnFunctionThenOnlyMatchingItemsReturned()
+		{
+			var results = _restContext.Query.Where(x => x.Children.All(y => x.StringValue.StartsWith(y.ChildStringValue))).ToList();
+			Assert.AreEqual(1, results.Count);
+			Assert.AreEqual("74", results.First().StringValue);
+		}
+	}
 }

File Linq2Rest.Tests/Provider/RestContextTests.cs

 	{
 		private RestContext<SimpleDto> _provider;
 		private RestContext<ComplexDto> _complexProvider;
-        private RestContext<CollectionDto> _collectionProvider;
+		private RestContext<CollectionDto> _collectionProvider;
 		private Mock<IRestClient> _mockClient;
 		private Mock<IRestClient> _mockComplexClient;
-        private Mock<IRestClient> _mockCollectionClient;
+		private Mock<IRestClient> _mockCollectionClient;
 
 		[SetUp]
 		public void TestSetup()
 			_mockComplexClient.Setup(x => x.Get(It.IsAny<Uri>()))
 				.Callback<Uri>(u => Console.WriteLine(u.ToString()))
 				.Returns("[{Value : 2, Content : \"blah\", Child : {ID : 2, Name : \"Foo\"}}]");
-            _complexProvider = new RestContext<ComplexDto>(_mockComplexClient.Object, serializerFactory);
+			_complexProvider = new RestContext<ComplexDto>(_mockComplexClient.Object, serializerFactory);
 
-            _mockCollectionClient = new Mock<IRestClient>();
-            _mockCollectionClient.SetupGet(x => x.ServiceBase).Returns(baseUri);
-            _mockCollectionClient.Setup(x => x.Get(It.IsAny<Uri>()))
-                .Callback<Uri>(u => Console.WriteLine(u.ToString()))
-                .Returns("[{Value : 2, Content : \"blah\", Children : [{ID : 1, Name : \"Foo\"}, {ID : 2, Name : \"Bar\"}]}]");
+			_mockCollectionClient = new Mock<IRestClient>();
+			_mockCollectionClient.SetupGet(x => x.ServiceBase).Returns(baseUri);
+			_mockCollectionClient.Setup(x => x.Get(It.IsAny<Uri>()))
+				.Callback<Uri>(u => Console.WriteLine(u.ToString()))
+				.Returns("[{Value : 2, Content : \"blah\", Children : [{ID : 1, Name : \"Foo\"}, {ID : 2, Name : \"Bar\"}]}]");
 
-            _collectionProvider = new RestContext<CollectionDto>(_mockCollectionClient.Object, serializerFactory);
+			_collectionProvider = new RestContext<CollectionDto>(_mockCollectionClient.Object, serializerFactory);
 		}
 
 		[Test]
 			VerifyCall(x => Math.Ceiling(x.Value) == 10d, "http://localhost/?$filter=ceiling(Value)+eq+10");
 		}
 
-        [Test]
-        public void WhenApplyingExpandThenCallsRestServiceWithExpandParameterSet() {
-            var result = _provider.Query
-                .Expand("Foo,Bar/Qux")
-                .ToList();
+		[Test]
+		public void WhenApplyingExpandThenCallsRestServiceWithExpandParameterSet()
+		{
+			var result = _provider.Query
+				.Expand("Foo,Bar/Qux")
+				.ToList();
 
-            var uri = new Uri("http://localhost/?$expand=Foo,Bar/Qux");
-            _mockClient.Verify(x => x.Get(uri), Times.Once());
-        }
+			var uri = new Uri("http://localhost/?$expand=Foo,Bar/Qux");
+			_mockClient.Verify(x => x.Get(uri), Times.Once());
+		}
 
-        [Test]
-        public void WhenApplyingExpandWithOrderByThenCallsRestServiceWithExpandParameterSet() {
-            var result = _provider.Query
-                .Expand("Foo,Bar/Qux")
-                .OrderBy(x => x.Date)
-                .ToList();
+		[Test]
+		public void WhenApplyingExpandWithOrderByThenCallsRestServiceWithExpandParameterSet()
+		{
+			var result = _provider.Query
+				.Expand("Foo,Bar/Qux")
+				.OrderBy(x => x.Date)
+				.ToList();
 
-            var uri = new Uri("http://localhost/?$orderby=Date&$expand=Foo,Bar/Qux");
-            _mockClient.Verify(x => x.Get(uri), Times.Once());
-        }
+			var uri = new Uri("http://localhost/?$orderby=Date&$expand=Foo,Bar/Qux");
+			_mockClient.Verify(x => x.Get(uri), Times.Once());
+		}
 
-        [Test]
-        public void WhenApplyingFilterWithAnyOnRootCollectionThenCallsRestServiceWithAnySyntax() {
-            var result = _collectionProvider.Query
-                .Where(x => x.Children.Any(y => y.ID == 2))
-                .ToList();
+		[Test]
+		public void WhenApplyingFilterWithAnyOnRootCollectionThenCallsRestServiceWithAnySyntax()
+		{
+			var result = _collectionProvider.Query
+				.Where(x => x.Children.Any(y => y.ID == 2))
+				.ToList();
 
-            _mockCollectionClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == "http://localhost/?$filter=Children/any(y:+y/ID+eq+2)")), Times.Once());
-        }
+			_mockCollectionClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == "http://localhost/?$filter=Children/any(y:+y/ID+eq+2)")), Times.Once());
+		}
 
-        [Test]
-        public void WhenApplyingFilterWithAllOnRootCollectionThenCallsRestServiceWithAllSyntax() {
-            var result = _collectionProvider.Query
-                .Where(x => x.Children.All(y => y.ID == 2))
-                .ToList();
+		[Test]
+		public void WhenApplyingFilterWithAllOnRootCollectionThenCallsRestServiceWithAllSyntax()
+		{
+			var result = _collectionProvider.Query
+				.Where(x => x.Children.All(y => y.ID == 2))
+				.ToList();
 
-            _mockCollectionClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == "http://localhost/?$filter=Children/all(y:+y/ID+eq+2)")), Times.Once());
-        }
+			_mockCollectionClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == "http://localhost/?$filter=Children/all(y:+y/ID+eq+2)")), Times.Once());
+		}
 
-        [Test]
-        public void WhenApplyingFilterWithAllOnRootCollectionAndFunctionThenCallsRestServiceWithAllSyntax() {
-            var result = _collectionProvider.Query
-                .Where(x => x.Children.All(y => y.ID == 2 + x.ID))
-                .ToList();
+		[Test]
+		public void WhenApplyingFilterWithAllOnRootCollectionAndFunctionThenCallsRestServiceWithAllSyntax()
+		{
+			var result = _collectionProvider.Query
+				.Where(x => x.Children.All(y => y.ID == 2 + x.ID))
+				.ToList();
 
-            _mockCollectionClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == "http://localhost/?$filter=Children/all(y:+y/ID+eq+2+add+ID)")), Times.Once());
-        }
+			_mockCollectionClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == "http://localhost/?$filter=Children/all(y:+y/ID+eq+2+add+ID)")), Times.Once());
+		}
 
 		private void VerifyCall(Expression<Func<SimpleDto, bool>> selection, string expectedUri)
 		{
 
 			_mockClient.Verify(x => x.Get(It.Is<Uri>(u => u.ToString() == expectedUri)), Times.Once());
 		}
-
-
 	}
 }

File Linq2Rest/LinqExtensions.cs

 // All other rights reserved.
 // Based on code from http://stackoverflow.com/questions/606104/how-to-create-linq-expression-tree-with-anonymous-type-in-it
 
-using System.Linq;
-using System.Linq.Expressions;
-using Linq2Rest.Provider;
-
 namespace Linq2Rest
 {
 	using System;
 				&& type.Name.Contains("AnonymousType") && (type.Name.StartsWith("<>") || type.Name.StartsWith("VB$"))
 				&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic;
 		}
-
-
-
 	}
 }

File Linq2Rest/MethodProvider.cs

 
 	internal static class MethodProvider
 	{
-		public static readonly ConstantExpression IgnoreCaseExpression;
-
+		private static readonly ConstantExpression InnerIgnoreCaseExpression;
 		private static readonly MethodInfo InnerContainsMethod;
 		private static readonly MethodInfo InnerIndexOfMethod;
 		private static readonly MethodInfo EndsWithMethod1;
 			var mathType = typeof(Math);
 			var stringComparisonType = typeof(StringComparison);
 
-			IgnoreCaseExpression = Expression.Constant(StringComparison.OrdinalIgnoreCase);
+			InnerIgnoreCaseExpression = Expression.Constant(StringComparison.OrdinalIgnoreCase);
 
 			InnerContainsMethod = stringType.GetMethod("Contains", new[] { stringType });
 			InnerIndexOfMethod = stringType.GetMethod("IndexOf", new[] { stringType, stringComparisonType });
 			DecimalCeilingMethod1 = mathType.GetMethod("Ceiling", new[] { typeof(decimal) });
 		}
 
+		public static ConstantExpression IgnoreCaseExpression
+		{
+			get
+			{
+				return InnerIgnoreCaseExpression;
+			}
+		}
+
 		public static MethodInfo IndexOfMethod
 		{
 			get
 			}
 		}
 
-        public static MethodInfo GetAnyMethod(Type collectionType) {
+		public static MethodInfo GetAnyMethod(Type collectionType)
+		{
+			var implementation = GetIEnumerableImpl(collectionType);
 
-            Type cType = GetIEnumerableImpl(collectionType);
-            
-            Type elemType = cType.GetGenericArguments()[0];
-            Type predType = typeof(Func<,>).MakeGenericType(elemType, typeof(bool));
+			var elemType = implementation.GetGenericArguments()[0];
+			var predType = typeof(Func<,>).MakeGenericType(elemType, typeof(bool));
 
-            // Enumerable.Any<T>(IEnumerable<T>, Func<T,bool>)
-            MethodInfo anyMethod = (MethodInfo)
-                GetGenericMethod(typeof(Enumerable), "Any", new[] { elemType },
-                    new[] { cType, predType }, BindingFlags.Static);
+			// Enumerable.Any<T>(IEnumerable<T>, Func<T,bool>)
+			var anyMethod = (MethodInfo)GetGenericMethod(
+														 typeof(Enumerable),
+														 "Any",
+														 new[] { elemType },
+														 new[] { implementation, predType },
+														 BindingFlags.Static);
 
-            return anyMethod;
-        }
+			return anyMethod;
+		}
 
-        public static MethodInfo GetAllMethod(Type collectionType) {
+		public static MethodInfo GetAllMethod(Type collectionType)
+		{
+			var implementationType = GetIEnumerableImpl(collectionType);
 
-            Type cType = GetIEnumerableImpl(collectionType);
+			var elemType = implementationType.GetGenericArguments()[0];
+			var predType = typeof(Func<,>).MakeGenericType(elemType, typeof(bool));
 
-            Type elemType = cType.GetGenericArguments()[0];
-            Type predType = typeof(Func<,>).MakeGenericType(elemType, typeof(bool));
+			// Enumerable.Any<T>(IEnumerable<T>, Func<T,bool>)
+			var allMethod = (MethodInfo)GetGenericMethod(
+														 typeof(Enumerable),
+														 "All",
+														 new[] { elemType },
+														 new[] { implementationType, predType },
+														 BindingFlags.Static);
 
-            // Enumerable.Any<T>(IEnumerable<T>, Func<T,bool>)
-            MethodInfo allMethod = (MethodInfo)
-                GetGenericMethod(typeof(Enumerable), "All", new[] { elemType },
-                    new[] { cType, predType }, BindingFlags.Static);
-            
-            return allMethod;
-        }
+			return allMethod;
+		}
 
+		public static Type GetIEnumerableImpl(Type type)
+		{
+			// Get IEnumerable implementation. Either type is IEnumerable<T> for some T, 
+			// or it implements IEnumerable<T> for some T. We need to find the interface.
+			if (IsIEnumerable(type))
+			{
+				return type;
+			}
 
-        static MethodBase GetGenericMethod(Type type, string name, Type[] typeArgs,
-    Type[] argTypes, BindingFlags flags) {
-            int typeArity = typeArgs.Length;
-            var methods = type.GetMethods()
-                .Where(m => m.Name == name)
-                .Where(m => m.GetGenericArguments().Length == typeArity)
-                .Select(m => m.MakeGenericMethod(typeArgs));
+			var t = type.FindInterfaces((m, o) => IsIEnumerable(m), null);
 
-            return Type.DefaultBinder.SelectMethod(flags, methods.ToArray(), argTypes, null);
-        }
+			Contract.Assert(t.Length == 1);
 
-        static bool IsIEnumerable(Type type) {
-            return type.IsGenericType
-                && type.GetGenericTypeDefinition() == typeof(IEnumerable<>);
-        }
+			return t[0];
+		}
 
-        public static Type GetIEnumerableImpl(Type type) {
-            // Get IEnumerable implementation. Either type is IEnumerable<T> for some T, 
-            // or it implements IEnumerable<T> for some T. We need to find the interface.
-            if (IsIEnumerable(type))
-                return type;
-            Type[] t = type.FindInterfaces((m, o) => IsIEnumerable(m), null);
-            Debug.Assert(t.Length == 1);
-            return t[0];
-        }
+		private static MethodBase GetGenericMethod(Type type, string name, Type[] typeArgs, Type[] argTypes, BindingFlags flags)
+		{
+			var typeArity = typeArgs.Length;
+			var methods = type.GetMethods()
+				.Where(m => m.Name == name)
+				.Where(m => m.GetGenericArguments().Length == typeArity)
+				.Select(m => m.MakeGenericMethod(typeArgs));
+
+			return Type.DefaultBinder.SelectMethod(flags, methods.ToArray(), argTypes, null);
+		}
+
+		private static bool IsIEnumerable(Type type)
+		{
+			return type.IsGenericType
+				&& type.GetGenericTypeDefinition() == typeof(IEnumerable<>);
+		}
 	}
 }

File Linq2Rest/Parser/FilterExpressionFactory.cs

 		private static readonly Regex StringRx = new Regex(@"^[""']([^""']*?)[""']$", RegexOptions.Compiled);
 		private static readonly Regex FunctionRx = new Regex(@"^([^\(\)]+)\((.+)\)$", RegexOptions.Compiled);
 		private static readonly Regex FunctionContentRx = new Regex(@"^(.*\((?>[^()]+|\((?<Depth>.*)|\)(?<-Depth>.*))*(?(Depth)(?!))\)|.*?)\s*,\s*(.+)$", RegexOptions.Compiled);
-	    private static readonly Regex AnyAllFunctionRx = new Regex(@"^(([0-9a-zA-Z_]*/)+)(any|all)\((.*)\)$");
+		private static readonly Regex AnyAllFunctionRx = new Regex(@"^(([0-9a-zA-Z_]*/)+)(any|all)\((.*)\)$");
 		private static readonly Regex NewRx = new Regex(@"^new (?<type>[^\(\)]+)\((?<parameters>.*)\)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
 		private static readonly ConcurrentDictionary<Type, MethodInfo> ParseMethods = new ConcurrentDictionary<Type, MethodInfo>();
 
 			return expression == null ? x => true : Expression.Lambda<Func<T, bool>>(expression, parameter);
 		}
 
-        private static TokenSet GetAnyAllFunctionTokens(string filter) {
-            Contract.Requires(filter != null);
+		private static TokenSet GetAnyAllFunctionTokens(string filter)
+		{
+			Contract.Requires(filter != null);
 
-            var functionMatch = AnyAllFunctionRx.Match(filter);
-            if (!functionMatch.Success) {
-                return null;
-            }
+			var functionMatch = AnyAllFunctionRx.Match(filter);
+			if (!functionMatch.Success)
+			{
+				return null;
+			}
 
-            var functionCollection = functionMatch.Groups[1].Value.Trim('/');
-            var functionName = functionMatch.Groups[3].Value;
-            var functionContent = functionMatch.Groups[4].Value;
+			var functionCollection = functionMatch.Groups[1].Value.Trim('/');
+			var functionName = functionMatch.Groups[3].Value;
+			var functionContent = functionMatch.Groups[4].Value;
 
-            return new FunctionTokenSet {
-                Operation = functionName,
-                Left = functionCollection,
-                Right = functionContent
-            };
-        }
+			return new FunctionTokenSet
+			{
+				Operation = functionName,
+				Left = functionCollection,
+				Right = functionContent
+			};
+		}
 
 		private static TokenSet GetFunctionTokens(string filter)
 		{
 			}
 		}
 
-		private static Expression GetPropertyExpression<T>(string propertyToken, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters )
+		private static Expression GetPropertyExpression<T>(string propertyToken, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters)
 		{
 			Contract.Requires(propertyToken != null);
 
 				var token = propertyToken.GetTokens().FirstOrDefault();
 				if (token != null)
 				{
-                    return GetPropertyExpression<T>(token.Left, parameter, lambdaParameters) ?? GetPropertyExpression<T>(token.Right, parameter, lambdaParameters);
+					return GetPropertyExpression<T>(token.Left, parameter, lambdaParameters) ?? GetPropertyExpression<T>(token.Right, parameter, lambdaParameters);
 				}
 			}
 
 
 			var propertyChain = propertyToken.Split('/');
 
-            if (propertyChain.Any() && lambdaParameters.Any(p => p.Name == propertyChain.First())) {
-                ParameterExpression lambdaParameter = lambdaParameters.First(p => p.Name == propertyChain.First());
-                parentType = lambdaParameter.Type;
-                propertyExpression = lambdaParameter;
-            }
+			if (propertyChain.Any() && lambdaParameters.Any(p => p.Name == propertyChain.First()))
+			{
+				ParameterExpression lambdaParameter = lambdaParameters.First(p => p.Name == propertyChain.First());
+				parentType = lambdaParameter.Type;
+				propertyExpression = lambdaParameter;
+			}
 
-		    foreach (var propertyName in propertyChain)
+			foreach (var propertyName in propertyChain)
 			{
 				var property = parentType.GetProperty(propertyName);
 				if (property != null)
 			return propertyExpression;
 		}
 
-		private static Type GetExpressionType<T>(TokenSet set, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters )
+		private static Type GetExpressionType<T>(TokenSet set, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters)
 		{
 			if (set == null)
 			{
 			throw new InvalidOperationException("Unsupported operation");
 		}
 
-		private static Expression GetFunction(string function, Expression left, Expression right, ParameterExpression sourceParameter, ICollection<ParameterExpression> lambdaParameters )
+		private static Expression GetFunction(string function, Expression left, Expression right, ParameterExpression sourceParameter, ICollection<ParameterExpression> lambdaParameters)
 		{
 			Contract.Requires(function != null);
 
 					Contract.Assume(left != null);
 
 					return Expression.Call(left.Type == typeof(double) ? MethodProvider.DoubleCeilingMethod : MethodProvider.DecimalCeilingMethod, left);
-                case "any":
-                    Contract.Assume(left != null);
+				case "any":
+					{
+						Contract.Assume(left != null);
 
-			        return Expression.Call(MethodProvider.GetAnyMethod(left.Type), left,
-			                               Expression.Lambda(
-			                                   typeof (Func<,>).MakeGenericType(
-			                                       MethodProvider.GetIEnumerableImpl(left.Type).GetGenericArguments()[0],
-			                                       typeof (bool)), right, new ParameterVisitor().GetParameters(right).Where(p => p.Name != sourceParameter.Name)));
-                case "all":
-                    Contract.Assume(left != null);
+						var genericFunc =
+							typeof(Func<,>).MakeGenericType(
+															MethodProvider.GetIEnumerableImpl(left.Type).GetGenericArguments()[0],
+															typeof(bool));
+						var parameters = new ParameterVisitor().GetParameters(right).Where(p => p.Name != sourceParameter.Name);
+						return Expression.Call(
+											   MethodProvider.GetAnyMethod(left.Type),
+											   left,
+											   Expression.Lambda(genericFunc, right, parameters));
+					}
 
-                    return Expression.Call(MethodProvider.GetAllMethod(left.Type), left, 
-                                            Expression.Lambda(
-                                                typeof(Func<,>).MakeGenericType(
-                                                    MethodProvider.GetIEnumerableImpl(left.Type).GetGenericArguments()[0], 
-                                                    typeof(bool)), right, new ParameterVisitor().GetParameters(right).Where(p => p.Name != sourceParameter.Name)));
+				case "all":
+					{
+						Contract.Assume(left != null);
+
+						var genericFunc =
+							typeof(Func<,>).MakeGenericType(
+															MethodProvider.GetIEnumerableImpl(left.Type).GetGenericArguments()[0],
+															typeof(bool));
+						var parameters = new ParameterVisitor().GetParameters(right).Where(p => p.Name != sourceParameter.Name);
+						return Expression.Call(
+											   MethodProvider.GetAllMethod(left.Type),
+											   left,
+											   Expression.Lambda(genericFunc, right, parameters));
+					}
+
 				default:
 					return null;
 			}
 		}
 
-        /// <summary>
-        /// Used to get the ParameterExpressions used in an Expression so that Expression.Call will have the correct number of parameters supplied
-        /// </summary>
-        private class ParameterVisitor : ExpressionVisitor {
-
-            List<ParameterExpression> m_Parameters;
-
-            public IEnumerable<ParameterExpression> GetParameters(Expression expr) {
-                m_Parameters = new List<ParameterExpression>();
-                Visit(expr);
-                return m_Parameters;
-            }
-
-            public override Expression Visit(Expression node) {
-                
-                if (node is MethodCallExpression && new[] { "Any", "All" }.Contains(((MethodCallExpression)node).Method.Name)) {
-                    // Skip the second parameter of the Any/All as this has already been covered
-                    return base.Visit(((MethodCallExpression) node).Arguments.First());
-                }
-                return base.Visit(node);
-            }
-
-            protected override System.Linq.Expressions.Expression VisitParameter(System.Linq.Expressions.ParameterExpression p) {
-                
-                if (!m_Parameters.Contains(p))
-                    m_Parameters.Add(p);
-
-                return base.VisitParameter(p);
-            }
-        }
-
 		private static Expression GetKnownConstant(string token, Type type, IFormatProvider formatProvider)
 		{
 			Contract.Requires(token != null);
 
 			return type.GetMethods(BindingFlags.Static | BindingFlags.Public)
 				.Where(x => x.Name == "Parse" && x.GetParameters().Length == 2)
-				.Where(x => x.GetParameters().First().ParameterType == typeof(string) && x.GetParameters().ElementAt(1).ParameterType == typeof(IFormatProvider))
-				.FirstOrDefault();
+				.FirstOrDefault(x => x.GetParameters().First().ParameterType == typeof(string) && x.GetParameters().ElementAt(1).ParameterType == typeof(IFormatProvider));
 		}
 
 		private Expression CreateExpression<T>(string filter, ParameterExpression sourceParameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider)
 				expression = Expression.Constant(stringMatch.Groups[1].Value, typeof(string));
 			}
 
-            if (expression == null) {
-                expression = GetAnyAllFunctionExpression<T>(filter, sourceParameter, lambdaParameters, type, formatProvider);
-            }
+			if (expression == null)
+			{
+				expression = GetAnyAllFunctionExpression<T>(filter, sourceParameter, lambdaParameters, type, formatProvider);
+			}
 
 			if (expression == null)
 			{
 						var right = CreateExpression<T>(
 														tokenSet.Right,
 														parameter,
-                                                        lambdaParameters,
+														lambdaParameters,
 														type ?? GetExpressionType<T>(tokenSet, parameter, lambdaParameters),
 														formatProvider);
 
 					var left = CreateExpression<T>(
 												   tokenSet.Left,
 												   parameter,
-                                                   lambdaParameters,
+												   lambdaParameters,
 												   type ?? GetExpressionType<T>(tokenSet, parameter, lambdaParameters),
 												   formatProvider);
 					var right = CreateExpression<T>(tokenSet.Right, parameter, lambdaParameters, left.Type, formatProvider);
 			return existing;
 		}
 
-        private Expression GetArithmeticExpression<T>(string filter, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider)
+		private Expression GetArithmeticExpression<T>(string filter, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider)
 		{
 			Contract.Requires(filter != null);
 
 			var rightExpression = CreateExpression<T>(arithmeticToken.Right, parameter, lambdaParameters, type1, formatProvider);
 
 			return leftExpression == null || rightExpression == null
-			       	? null
-			       	: GetLeftRightOperation(arithmeticToken.Operation, leftExpression, rightExpression);
+					? null
+					: GetLeftRightOperation(arithmeticToken.Operation, leftExpression, rightExpression);
 		}
 
-        private Expression GetConstructorExpression<T>(string filter, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters, Type resultType, IFormatProvider formatProvider)
+		private Expression GetConstructorExpression<T>(string filter, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters, Type resultType, IFormatProvider formatProvider)
 		{
 			Contract.Requires(filter != null);
 
 			return null;
 		}
 
-        private Expression GetAnyAllFunctionExpression<T>(string filter, ParameterExpression sourceParameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider) {
-            Contract.Requires(filter != null);
+		private Expression GetAnyAllFunctionExpression<T>(string filter, ParameterExpression sourceParameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider)
+		{
+			Contract.Requires(filter != null);
 
-            var functionTokens = GetAnyAllFunctionTokens(filter);
-            if (functionTokens == null) {
-                return null;
-            }
+			var functionTokens = GetAnyAllFunctionTokens(filter);
+			if (functionTokens == null)
+			{
+				return null;
+			}
 
-            //Type leftType = type ?? GetExpressionType<T>(functionTokens, sourceParameter, lambdaParameters);
-            Type leftType = GetPropertyExpression<T>(functionTokens.Left, sourceParameter, lambdaParameters).Type;
-            var left = CreateExpression<T>(
-                functionTokens.Left,
-                sourceParameter,
-                lambdaParameters,
-                leftType,
-                formatProvider);
+			var leftType = GetPropertyExpression<T>(functionTokens.Left, sourceParameter, lambdaParameters).Type;
+			var left = CreateExpression<T>(
+				functionTokens.Left,
+				sourceParameter,
+				lambdaParameters,
+				leftType,
+				formatProvider);
 
-            // Create a new ParameterExpression from the lambda parameter and add to a collection to pass around
-            string parameterName = functionTokens.Right.Substring(0, functionTokens.Right.IndexOf(":")).Trim();
-            ParameterExpression lambdaParameter =
-                Expression.Parameter(MethodProvider.GetIEnumerableImpl(leftType).GetGenericArguments()[0], parameterName);
-            lambdaParameters.Add(lambdaParameter);
-            var right = CreateExpression<T>(functionTokens.Right.Substring(functionTokens.Right.IndexOf(":") + 1).Trim(), sourceParameter, lambdaParameters, GetFunctionParameterType(functionTokens.Operation) ?? left.Type, formatProvider);
+			// Create a new ParameterExpression from the lambda parameter and add to a collection to pass around
+			string parameterName = functionTokens.Right.Substring(0, functionTokens.Right.IndexOf(":")).Trim();
+			ParameterExpression lambdaParameter =
+				Expression.Parameter(MethodProvider.GetIEnumerableImpl(leftType).GetGenericArguments()[0], parameterName);
+			lambdaParameters.Add(lambdaParameter);
+			var right = CreateExpression<T>(functionTokens.Right.Substring(functionTokens.Right.IndexOf(":") + 1).Trim(), sourceParameter, lambdaParameters, GetFunctionParameterType(functionTokens.Operation) ?? left.Type, formatProvider);
 
-            return GetFunction(functionTokens.Operation, left, right, sourceParameter, lambdaParameters);
-        }
+			return GetFunction(functionTokens.Operation, left, right, sourceParameter, lambdaParameters);
+		}
 
-        private Expression GetFunctionExpression<T>(string filter, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider)
+		private Expression GetFunctionExpression<T>(string filter, ParameterExpression parameter, ICollection<ParameterExpression> lambdaParameters, Type type, IFormatProvider formatProvider)
 		{
 			Contract.Requires(filter != null);
 
 			var left = CreateExpression<T>(
 				functionTokens.Left,
 				parameter,
-                lambdaParameters,
+				lambdaParameters,
 				type ?? GetExpressionType<T>(functionTokens, parameter, lambdaParameters),
 				formatProvider);
 
 
 			return GetFunction(functionTokens.Operation, left, right, parameter, lambdaParameters);
 		}
+
+		/// <summary>
+		/// Used to get the ParameterExpressions used in an Expression so that Expression.Call will have the correct number of parameters supplied.
+		/// </summary>
+		private class ParameterVisitor : ExpressionVisitor
+		{
+			List<ParameterExpression> _parameters;
+
+			public IEnumerable<ParameterExpression> GetParameters(Expression expr)
+			{
+				_parameters = new List<ParameterExpression>();
+				Visit(expr);
+				return _parameters;
+			}
+
+			public override Expression Visit(Expression node)
+			{
+				if (node is MethodCallExpression && new[] { "Any", "All" }.Contains(((MethodCallExpression)node).Method.Name))
+				{
+					// Skip the second parameter of the Any/All as this has already been covered
+					return base.Visit(((MethodCallExpression)node).Arguments.First());
+				}
+
+				return base.Visit(node);
+			}
+
+			protected override Expression VisitParameter(ParameterExpression p)
+			{
+				if (!_parameters.Contains(p))
+				{
+					_parameters.Add(p);
+				}
+
+				return base.VisitParameter(p);
+			}
+		}
 	}
 }

File Linq2Rest/Provider/ExpressionProcessor.cs

 						{
 							return InvokeEager(methodCall, result);
 						}
+
                         var objectMember = Expression.Convert(methodCall.Arguments[1], typeof(object));
                         var getterLambda = Expression.Lambda<Func<object>>(objectMember).Compile();
                         

File Linq2Rest/Provider/ExpressionVisitor.cs

 
 		public string Visit(Expression expression)
 		{
-            return expression == null ? null : Visit(expression, expression.Type, GetRootParameterName(expression));
+			return expression == null ? null : Visit(expression, expression.Type, GetRootParameterName(expression));
 		}
 
-        private string Visit(Expression expression, string rootParameterName) {
-            return expression == null ? null : Visit(expression, expression.Type, rootParameterName);
-        }
-
-        private string GetRootParameterName(Expression expression) {
-            if (expression is UnaryExpression) {
-                expression = ((UnaryExpression) expression).Operand;
-            }
-
-            if (expression is LambdaExpression && ((LambdaExpression)expression).Parameters.Count > 0) {
-                return ((LambdaExpression) expression).Parameters.First().Name;
-            }
-            return null;
-        }
-
-	    private static Type GetUnconvertedType(Expression expression)
+		private static Type GetUnconvertedType(Expression expression)
 		{
 #if !SILVERLIGHT
 			Contract.Requires(expression != null);
 			return string.Empty;
 		}
 
+		private string Visit(Expression expression, string rootParameterName)
+		{
+			return expression == null ? null : Visit(expression, expression.Type, rootParameterName);
+		}
+
+		private string GetRootParameterName(Expression expression)
+		{
+			if (expression is UnaryExpression)
+			{
+				expression = ((UnaryExpression)expression).Operand;
+			}
+
+			if (expression is LambdaExpression && ((LambdaExpression)expression).Parameters.Count > 0)
+			{
+				return ((LambdaExpression)expression).Parameters.First().Name;
+			}
+
+			return null;
+		}
+
 		private string GetMethodCall(MethodCallExpression expression, string rootParameterName)
 		{
 #if !SILVERLIGHT
 			{
 				var obj = expression.Object;
 #if !SILVERLIGHT
-                Contract.Assume(obj != null);
+				Contract.Assume(obj != null);
 #endif
 
 				switch (methodName)
 							return string.Format(
 								"replace({0}, {1}, {2})",
 								Visit(obj, rootParameterName),
-                                Visit(firstArgument, rootParameterName),
-                                Visit(secondArgument, rootParameterName));
+								Visit(firstArgument, rootParameterName),
+								Visit(secondArgument, rootParameterName));
 						}
 
 					case "Trim":
-                        return string.Format("trim({0})", Visit(obj, rootParameterName));
+						return string.Format("trim({0})", Visit(obj, rootParameterName));
 					case "ToLower":
 					case "ToLowerInvariant":
-                        return string.Format("tolower({0})", Visit(obj, rootParameterName));
+						return string.Format("tolower({0})", Visit(obj, rootParameterName));
 					case "ToUpper":
 					case "ToUpperInvariant":
-                        return string.Format("toupper({0})", Visit(obj, rootParameterName));
+						return string.Format("toupper({0})", Visit(obj, rootParameterName));
 					case "Substring":
 						{
 #if !SILVERLIGHT
 #endif
 
 								return string.Format(
-                                    "substring({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
+									"substring({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
 							}
 
 							var firstArgument = expression.Arguments[0];
 
 							return string.Format(
 								"substring({0}, {1}, {2})",
-                                Visit(obj, rootParameterName),
-                                Visit(firstArgument, rootParameterName),
-                                Visit(secondArgument, rootParameterName));
+								Visit(obj, rootParameterName),
+								Visit(firstArgument, rootParameterName),
+								Visit(secondArgument, rootParameterName));
 						}
 
 					case "IndexOf":
 							Contract.Assume(argumentExpression != null);
 #endif
 
-                            return string.Format("indexof({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
+							return string.Format("indexof({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
 						}
 
 					case "EndsWith":
 							Contract.Assume(argumentExpression != null);
 #endif
 
-                            return string.Format("endswith({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
+							return string.Format("endswith({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
 						}
 
 					case "StartsWith":
 							Contract.Assume(argumentExpression != null);
 #endif
 
-                            return string.Format("startswith({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
+							return string.Format("startswith({0}, {1})", Visit(obj, rootParameterName), Visit(argumentExpression, rootParameterName));
 						}
 				}
 			}
 				switch (methodName)
 				{
 					case "Round":
-                        return string.Format("round({0})", Visit(mathArgument, rootParameterName));
+						return string.Format("round({0})", Visit(mathArgument, rootParameterName));
 					case "Floor":
-                        return string.Format("floor({0})", Visit(mathArgument, rootParameterName));
+						return string.Format("floor({0})", Visit(mathArgument, rootParameterName));
 					case "Ceiling":
-                        return string.Format("ceiling({0})", Visit(mathArgument, rootParameterName));
+						return string.Format("ceiling({0})", Visit(mathArgument, rootParameterName));
 				}
 			}
 
-            if (expression.Method.Name == "Any" || expression.Method.Name == "All") 
-            {
-                Contract.Assume(expression.Arguments.Count > 1);
+			if (expression.Method.Name == "Any" || expression.Method.Name == "All")
+			{
+#if !SILVERLIGHT
+				Contract.Assume(expression.Arguments.Count > 1);
+#endif
 
-                return string.Format("{0}/{1}({2}: {3})", Visit(expression.Arguments[0], rootParameterName), expression.Method.Name.ToLowerInvariant(), expression.Arguments[1] is LambdaExpression ? (expression.Arguments[1] as LambdaExpression).Parameters.First().Name : null, Visit(expression.Arguments[1], rootParameterName));
-            }
+				return string.Format("{0}/{1}({2}: {3})", Visit(expression.Arguments[0], rootParameterName), expression.Method.Name.ToLowerInvariant(), expression.Arguments[1] is LambdaExpression ? (expression.Arguments[1] as LambdaExpression).Parameters.First().Name : null, Visit(expression.Arguments[1], rootParameterName));
+			}
 
-		    if (expression.Method.IsStatic)
+			if (expression.Method.IsStatic)
 			{
 				return expression.ToString();
 			}
 			if (memberExpression != null)
 			{
 				var pathPrefixes = new List<string>();
-                
-			    var currentMemberExpression = memberExpression;
+
+				var currentMemberExpression = memberExpression;
 				while (currentMemberExpression != null)
 				{
 					pathPrefixes.Add(currentMemberExpression.Member.Name);
-                    if (currentMemberExpression.Expression is ParameterExpression && ((ParameterExpression)currentMemberExpression.Expression).Name != rootParameterName) {
-                        pathPrefixes.Add(((ParameterExpression)currentMemberExpression.Expression).Name);
-                    }
+					if (currentMemberExpression.Expression is ParameterExpression && ((ParameterExpression)currentMemberExpression.Expression).Name != rootParameterName)
+					{
+						pathPrefixes.Add(((ParameterExpression)currentMemberExpression.Expression).Name);
+					}
+
 					currentMemberExpression = currentMemberExpression.Expression as MemberExpression;
 				}
 
-
 				pathPrefixes.Reverse();
 				var prefix = string.Join("/", pathPrefixes);
 
 						Contract.Assume(collapsedExpression != null);
 #endif
 
-                        return Visit(collapsedExpression, rootParameterName);
+						return Visit(collapsedExpression, rootParameterName);
 					}
 
 					memberExpression = (MemberExpression)collapsedExpression;
 
 				return string.IsNullOrWhiteSpace(memberCall)
 						? prefix
-                        : string.Format("{0}({1})", memberCall, Visit(innerExpression, rootParameterName));
+						: string.Format("{0}({1})", memberCall, Visit(innerExpression, rootParameterName));
 			}
 
 			if (expression is ConstantExpression)
 #if !SILVERLIGHT
 					case ExpressionType.IsFalse:
 #endif
-                        return string.Format("not({0})", Visit(operand, rootParameterName));
+						return string.Format("not({0})", Visit(operand, rootParameterName));
 					default:
 						return Visit(operand, rootParameterName);
 				}
 				var isRightComposite = CompositeExpressionTypes.Any(x => x == binaryExpression.Right.NodeType);
 
 				var leftType = GetUnconvertedType(binaryExpression.Left);
-                var leftString = Visit(binaryExpression.Left, rootParameterName);
+				var leftString = Visit(binaryExpression.Left, rootParameterName);
 				var rightString = Visit(binaryExpression.Right, leftType, rootParameterName);
 
 				return string.Format(

File Linq2Rest/Provider/ParameterBuilder.cs

 
 		public string TakeParameter { get; set; }
 
-        public string ExpandParameter { get; set; }
+		public string ExpandParameter { get; set; }
 
 		public Uri GetFullUri()
 		{
 				parameters.Add(BuildParameter(StringConstants.OrderByParameter, string.Join(",", OrderByParameter)));
 			}
 
-            if (!string.IsNullOrWhiteSpace(ExpandParameter)) {
-                parameters.Add(BuildParameter(StringConstants.ExpandParameter, ExpandParameter));
-            }
+			if (!string.IsNullOrWhiteSpace(ExpandParameter))
+			{
+				parameters.Add(BuildParameter(StringConstants.ExpandParameter, ExpandParameter));
+			}
 
 			var builder = new UriBuilder(_serviceBase);
 			builder.Query = (string.IsNullOrEmpty(builder.Query) ? string.Empty : "&") + string.Join("&", parameters);

File Linq2Rest/Provider/QueryableExtensions.cs

 // Please see http://www.opensource.org/licenses/MS-PL] for details.
 // All other rights reserved.
 
-using System.Linq.Expressions;
-using System.Reflection;
-
 namespace Linq2Rest.Provider
 {
 	using System;
 	using System.Collections.Generic;
 	using System.Diagnostics.Contracts;
 	using System.Linq;
+	using System.Linq.Expressions;
+	using System.Reflection;
 	using System.Threading.Tasks;
 
 	/// <summary>
 			return Task.Factory.StartNew(() => queryable.ToArray().AsEnumerable());
 		}
 
-        /// <summary>
-        /// Expands the specified source.
-        /// </summary>
-        /// <typeparam name="TSource"></typeparam>
-        /// <param name="source">The source.</param>
-        /// <param name="paths">The paths to expand in the format "Child1, Child2/GrandChild2".</param>
-        /// <returns></returns>
-        public static IQueryable<TSource> Expand<TSource>(this IQueryable<TSource> source, string paths) {
+		/// <summary>
+		/// Expands the specified source.
+		/// </summary>
+		/// <typeparam name="TSource"></typeparam>
+		/// <param name="source">The source.</param>
+		/// <param name="paths">The paths to expand in the format "Child1, Child2/GrandChild2".</param>
+		/// <returns></returns>
+		public static IQueryable<TSource> Expand<TSource>(this IQueryable<TSource> source, string paths)
+		{
+			if (source == null)
+			{
+				throw new ArgumentNullException("source");
+			}
 
-            if (source == null) {
-                throw new ArgumentNullException("source");
-            }
-            if (!(source is RestQueryable<TSource>)) {
-                return source;
-            }
-            return source.Provider.CreateQuery<TSource>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new[] { typeof(TSource) }), new[] { source.Expression, Expression.Constant(paths) }));
-        }
+			if (!(source is RestQueryable<TSource>))
+			{
+				return source;
+			}
 
-        /// <summary>
-        /// Expands the specified source.
-        /// </summary>
-        /// <typeparam name="TSource"></typeparam>
-        /// <param name="source">The source.</param>
-        /// <param name="paths">The paths to expand in the format "Child1, Child2/GrandChild2".</param>
-        /// <returns></returns>
-        public static IOrderedQueryable<TSource> Expand<TSource>(this IOrderedQueryable<TSource> source, string paths) {
-            if (source == null) {
-                throw new ArgumentNullException("source");
-            }
-            if (!(source is RestQueryable<TSource>)) {
-                return source;
-            }
-            return source.Provider.CreateQuery<TSource>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new[] { typeof(TSource) }), new[] { source.Expression, Expression.Constant(paths) })) as IOrderedQueryable<TSource>;
-        }
+			return source.Provider.CreateQuery<TSource>(Expression.Call(null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new[] { typeof(TSource) }), new[] { source.Expression, Expression.Constant(paths) }));
+		}
 	}
 }