0

Have all a structure for creating complex queries and obtaining data on the client side using Breeze and webapi IQueryable<T>.

I would use this structure on the client side to call another webapi controller, intercept the result of the query, and use this to make an Excel file returned by HttpResponseMessage.

See: Returning binary file from controller in ASP.NET Web API

How can I use the executeQuery without getting return data in standard Breeze JSON and without interfering with the data on the client side cache to have the 'octet-stream'.

The goal is to create an 'Export to Excel' without existing frontend paging for a large volume of data.

Community
  • 1
  • 1
julianpaulozzi
  • 323
  • 3
  • 12

2 Answers2

1

If you don't want to track changes, call EntityQuery.noTracking() before calling executeQuery(). This will return raw javascript objects without breeze tracking capabilities.

You can't make executeQuery() return binary 'octet-stream' data. But you can use breeze ajax implementation:

var ajaxImpl = breeze.config.getAdapterInstance("ajax");
ajaxImpl.ajax() // by default it is a wrapper to jQuery.ajax

Look http://www.breezejs.com/documentation/customizing-ajax

Didar_Uranov
  • 1,230
  • 11
  • 26
0

Create a custom "data service adapter" and specify it when you create an EntityManager for this special purpose. It can be quite simple because you disable the most difficult parts to implement, the metadata and saveChanges methods.

You don't want to cache the results. Therefore, you make sure the manager's metadata store is empty and you should add the " no caching" QueryOption. [exact names escape me as I write this on my phone].

Make sure these steps are really adding tangible value

Specialized server operations often can be performed more simply with native AJAX components.

p.s. I just saw @didar 's answer which is consistent with mine. Blend these thoughts into your solution.

Ward
  • 17,793
  • 4
  • 37
  • 53
  • Can probably more simply with native AJAX components. What really would like to take are my methods that create the 'EntityQuery' on client. Especially the 'Request URL' that call 'executeQuery' sends with all parameters. Any way to get these 'URLs' using 'EntityQuery' like 'Uri builder' for a call of a standard web api with Queryable (OData) attribute? – julianpaulozzi Apr 28 '14 at 19:24
  • Look for the recipe inside any "data service adapter". The components called are probably accessible (else how would you write your own adapter?). It isn't something we talk about ... in part because we don't feel we have seen a wide enough variety of remote service APIs to lock down the adapter API. Looking at the adapter code for inspiration puts you in the same boat as I am in. :) – Ward Apr 29 '14 at 00:01
  • This almost everything there. The only thing that fails is the way to intercept the query in webapi call. I use 'ApplyTo' method of the 'ODataQueryOptions' passed as parameter automatically by the api. The query comes with everything however have errors like "The binary operator with incompatible types was detected". I use BreezeQueryable with BreezeController not the standard odata. Resources for this parameter are incompatible with the standard breeze? – julianpaulozzi Apr 29 '14 at 20:33
  • The DataService must have Metadata for some resolutions, added fetchMetadata on my custom adapter and all goes well. – julianpaulozzi Apr 30 '14 at 01:42