@@ -14,26 +14,33 @@ namespace SolrNet.IntegrationOData.Controllers
1414 [ ApiController ]
1515 public class ValuesController : ControllerBase
1616 {
17+ public ISolrOperations < Product > Solr { get ; }
18+
19+ public ValuesController ( ISolrOperations < Product > solr )
20+ {
21+ Solr = solr ?? throw new ArgumentNullException ( nameof ( solr ) ) ;
22+ }
1723 // GET api/values
1824 [ HttpGet ]
1925 public IActionResult Get ( )
2026 {
21- return this . Ok ( new string [ ]
27+ return this . Ok ( new [ ]
2228 {
23- "http://localhost:64623/api/values/1?$filter=price gt 100&$orderby=Popularity desc&$top=3&$skip=1" ,
24- "http://localhost:64623/api/values/1?$filter=Popularity ne null" ,
25- "http://localhost:64623/api/values/1?$filter=Popularity eq null" ,
29+ "/api/values/1?$filter=price gt 100&$orderby=Popularity desc&$top=3&$skip=1" ,
30+ "/api/values/1?$filter=Popularity ne null" ,
31+ "/api/values/1?$filter=Popularity eq null" ,
32+ "/api/values/1?$filter=Categories/any(c: c eq 'electronics')" ,
2633 } ) ;
2734 }
2835
2936 // GET api/values/5
3037 [ HttpGet ( "{id}" ) ]
3138 public ActionResult < string > Get ( int id , ODataQueryOptions odata )
3239 {
33- Product . SolrOperations . Value . AsQueryable ( options =>
40+ SolrQuery < Product > query = this . Solr . AsQueryable ( options =>
3441 {
3542 // Set q parameter. By default *:* will be used
36- options . MainQuery = new SolrQuery ( "some query " ) ;
43+ options . MainQuery = new SolrQuery ( "*:* " ) ;
3744
3845 // Configure SolrNet QueryOptions.
3946 // This function will be called after applying query options from LINQ
@@ -46,7 +53,8 @@ public ActionResult<string> Get(int id, ODataQueryOptions odata)
4653 // override default serializer if needed
4754 options . SolrFieldSerializer = new DefaultFieldSerializer ( ) ;
4855 } ) ;
49- return this . Ok ( Product . SolrOperations . Value . AsQueryable ( ) . OData ( ) . ApplyQueryOptionsWithoutSelectExpand ( odata ) . ToSolrQueryResults ( ) ) ;
56+
57+ return this . Ok ( query . OData ( ) . ApplyQueryOptionsWithoutSelectExpand ( odata ) . ToSolrQueryResults ( ) ) ;
5058 }
5159
5260 // POST api/values
0 commit comments