示例#1
0
        /// <summary>
        /// Resolves the parsed URI against the data store.
        /// </summary>
        /// <param name="model">The data store model.</param>
        /// <param name="dataContext">The data access context.</param>
        /// <returns>The results of querying the data store.</returns>
        public object ResolveQuery(IEdmModel model, DataContext dataContext)
        {
            var queryProvider = new EntityFrameworkQueryProvider(dataContext);
            var testExpressionVisitor = new ODataUriToExpressionTranslator(queryProvider, model);

            // build linq expression from ODataPath and execute the expression 
            Expression boundExpression = Expression.Constant(null);
            foreach (var segment in this.QueryPath)
            {
                boundExpression = segment.TranslateWith(testExpressionVisitor);
            }

            boundExpression = Expression.Convert(boundExpression, typeof(object));
            Expression<Func<object>> lambda = Expression.Lambda<Func<object>>(boundExpression);

            Func<object> compiled = lambda.Compile();
            return compiled();
        }
 /// <summary>
 /// Creates or Initializes an instance of the EntityFrameworkQueryProvider Type
 /// </summary>
 /// <param name="context">The objectcontext instance to get the root queries from</param>
 public EntityFrameworkQueryProvider(DataContext context)
 {
     this.contextInstance = context;
 }