public NHQueryProvider(DefaultQueryProvider source) : this(source.Session, source.Collection) { // copy the private _options from the source var prop = source.GetType().GetField("_options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var options = prop.GetValue(source); prop.SetValue(this, options); }
public void CreateQueryable() { var provider = new DefaultQueryProvider(typeof(TestQueryable <>), _parserStub, _executorStub); var expression = Expression.Constant(new[] { 0 }); var queryable = provider.CreateQuery <int> (expression); Assert.That(queryable, Is.InstanceOf(typeof(TestQueryable <int>))); Assert.That(queryable.Provider, Is.SameAs(provider)); Assert.That(queryable.Expression, Is.SameAs(expression)); }
public void CreateQueryable () { var provider = new DefaultQueryProvider (typeof (TestQueryable<>), _parserStub, _executorStub); var expression = Expression.Constant (new[] {0}); var queryable = provider.CreateQuery<int> (expression); Assert.That (queryable, Is.InstanceOf (typeof (TestQueryable<int>))); Assert.That (queryable.Provider, Is.SameAs (provider)); Assert.That (queryable.Expression, Is.SameAs (expression)); }
/// <summary>Gets the underlying entity source query string.</summary> /// <returns>String with a query string to be run on the underlying entity source.</returns> public string ToTraceString() { DefaultQueryProvider provider = Provider as DefaultQueryProvider; if (provider == null) { throw new InvalidOperationException("Unsupported query provider."); } EntityQueryExecutor executor = provider.Executor as EntityQueryExecutor; if (executor == null) { throw new InvalidOperationException("Unsupported query executor."); } return(executor.GetCommandText(provider.GenerateQueryModel(Expression))); }
private static IQuery GetQueryFromExpression(ISessionImplementor sessionImplementor, Expression expression) { var provider = new DefaultQueryProvider(sessionImplementor); IQuery query = null; NhLinqExpression nhQuery = null; var parameters = new object[] {expression, query, nhQuery}; var parameterTypes = new[] { typeof(Expression), typeof(IQuery).MakeByRefType(), typeof(NhLinqExpression).MakeByRefType() }; provider.GetType() .GetMethod("PrepareQuery", InstanceNonPublicBinding, null, parameterTypes, null) .Invoke(provider, parameters); query = parameters[1] as IQuery; return query; }
private IncludeQueryProvider(System.Type type, DefaultQueryProvider queryProvider, IEnumerable <string> includePaths, IncludeOptions includeOptions) : this(type, queryProvider) { IncludePaths.AddRange(includePaths); _includeOptions = includeOptions; }
public IncludeQueryProvider(System.Type type, DefaultQueryProvider queryProvider) { Type = type; _queryProvider = queryProvider; }
/// <summary> /// Constructs an <see cref="T:System.Linq.IQueryable`1"/> object that can evaluate the query represented by a specified expression tree. /// </summary> /// <returns> /// An <see cref="T:System.Linq.IQueryable`1"/> that can evaluate the query represented by the specified expression tree. /// </returns> /// <param name="expression">An expression tree that represents a LINQ query.</param><typeparam name="TElement">The type of the elements of the <see cref="T:System.Linq.IQueryable`1"/> that is returned.</typeparam> public override IQueryable <TElement> CreateQuery <TElement>(Expression expression) { var queryProvider = new DefaultQueryProvider(typeof(EntityFrameworkQueryable <>), _queryParser, _queryExecutor); return(new EntityFrameworkQueryable <TElement>(queryProvider, expression)); }