public QueryExpressionXmlConverter(QueryCreator @creator = null, TypeResolver resolver = null)
		{
			this.creator = @creator;
			this.resolver = resolver;
		}
Exemplo n.º 2
0
		public void QueryExpressionXmlConverterTest()
		{
			Type elementType = typeof(Customer);
			var creator = new QueryCreator(this.FnGetObjects);
			var converter = new QueryExpressionXmlConverter(creator, this.resolver);
			bool success;
			XElement x;
			Expression e;
			MethodCallExpression m;
			ConstantExpression cx;
			IQueryProvider provider;

			//the client Query. IQueryProvider has not real data.
			Query<Customer> query = new Query<Customer>(default(IQueryProvider));
			provider = ((IQueryable)query).Provider;
			IQueryable<Customer> queryable;			
			queryable = from c in query
						where c.ID == null //initialized with properties == null
						select c;

			//serialize to XML
			e = Expression.Constant(queryable);
			success = converter.TrySerialize(e, out x);

			//deserialize to ConstantExpression(Query)			
			success = converter.TryDeserialize(x, out e);
			cx = (ConstantExpression)e;
			Query<Customer> serverquery = (Query<Customer>)cx.Value;
			//upon deserialization, should have a new IQueryProvider
			Assert.AreNotEqual(provider, ((IQueryable)serverquery).Provider);
			provider = ((IQueryable)serverquery).Provider;
			
			//Execute Query on server side.
			int count = serverquery.Count();

		}
Exemplo n.º 3
0
 public QueryExpressionXmlConverter(QueryCreator creator = null, TypeResolver resolver = null)
 {
     this.creator  = creator;
     this.resolver = resolver;
 }
Exemplo n.º 4
0
		public void CreateNewQuery_Execute()
		{
			QueryCreator creator = new QueryCreator();
			Type elementType = typeof(Customer);
			Query<Customer> query = creator.CreateQuery(elementType);
			IQueryable<Customer> queryable;

			queryable = from c in query
					where c.ID == null //initialized with properties == null
					select c;
			IQueryProvider provider = ((IQueryable)query).Provider;

			//execute:
			var ienumerable = provider.Execute<IEnumerable<Customer>>(queryable.Expression);
			var list = ienumerable.ToList();

			//new QueryCreator:
			creator = new QueryCreator(this.FnGetObjects);
			query = creator.CreateQuery(elementType);
			queryable = from c in query
						where c.ID == null //initialized with properties == null
						select c;
			provider.Execute<IEnumerable<Customer>>(queryable.Expression).ToList();
		}