Example #1
0
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapODataRoute("Nephos", "sdata", GetImplicitEDM());

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            // Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable<T> return type.
            // To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
            // For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
            var queryAttribute = new QueryableAttribute()
            {
                AllowedQueryOptions = AllowedQueryOptions.All, // or just some: AllowedQueryOptions.Top | AllowedQueryOptions.Skip,
                MaxTop = 100,
                PageSize = 100,
            };
            //config.EnableQuerySupport(queryAttribute);
            // no argument also allowed and then specify queryable attribute on controller
            config.EnableQuerySupport();

            // To disable tracing in your application, please comment out or remove the following line of code
            // For more information, refer to: http://www.asp.net/web-api
            config.EnableSystemDiagnosticsTracing();

            SDataMessageHandler sdataHandler = new SDataMessageHandler();
            // optionally add mapper that's a work around for web api odata not supporting property name aiasing
            sdataHandler.AddContentMap(new DefaultMetadataMap());
            sdataHandler.SetErrorResponseBuilder(new DefaultErrorResponseBuilder());
            GlobalConfiguration.Configuration.MessageHandlers.Add(sdataHandler);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TableFilterProvider"/> using the provided <see cref="QueryableAttribute"/>
        /// implementation for executing the query. 
        /// </summary>
        public TableFilterProvider(IActionFilter queryFilter)
        {
            if (queryFilter == null)
            {
                throw new ArgumentNullException("queryFilter");
            }

            this.queryFilter = new QueryableAttribute() { PageSize = TableUtils.PageSize };
            this.queryFilterProvider = new QueryFilterProvider(queryFilter);
            this.tableFilter = new FilterInfo(new TableQueryFilter(), FilterScope.Global);
        }