0

I am using WebApi and want to implement OData for one of my SolrNet resources.

WebApi supports OData if you return it an IQueryable. So I need an IQueryable provider for SolrNet queries.

Does anyone know of any, or some sample code of how I can get started? If there are none available my company might start an open source project for creating this.

BradLaney
  • 2,384
  • 1
  • 19
  • 28

3 Answers3

1

I know, the question is very old, but just in case if somebody need it after 5 years - here is my implementation of Linq to Solr IQueriable

Git Hub Project

https://github.com/DanielLavrushin/LinqToSolr/

Nuget Package

https://www.nuget.org/packages/LinqToSolr/

DolceVita
  • 2,090
  • 1
  • 23
  • 35
0

Generally speaking an IQueryable is associated with a LINQ provider of some sort. I'm not sure where the community is at with LINQ-to-Solr providers. I'm not aware of anything that works today but some projects showed up in search results that you should look at before investing time in creating a LINQ provider.

That said, you -could- simply take a list of things and call the .AsQueryable() extension method. Although it's technically easy to get an IQueryable this way, I assume you're probably looking for the OData query to be translated to a Solr query, in which case the former paragraph is the one you want to pursue.

Mark Stafford - MSFT
  • 4,306
  • 3
  • 17
  • 23
  • I have been looking, and couldn't find any projects. That's really the goal of this post, is to see if anyone has any recommendations. – BradLaney Aug 14 '12 at 20:07
0

You can use https://www.nuget.org/packages/SolrNet.Linq nuget package. It extend SolrNet functionality and compatible with OData way of building LINQ expressions, however support limited number of methods.

Code sample would be:

var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
IQueryable<Product> solrLinq = solr.AsQuerable()
Product[] result = solrLinq.Where(p => p.Price > 12).ToArray();
Ihar Yakimush
  • 562
  • 4
  • 6