Dependency on Linq to SQL?

Feb 27, 2009 at 12:31 AM
Edited Feb 27, 2009 at 12:35 AM
I might be being stupid (it's late at night) but does Linq to Lucene have any hard dependency on Linq to SQL? I can see that there are methods for generating an index from a Linq2SQL data context, but is that the only relationship? The reason I ask is that I already have an index created using another method, but I'd quite like to query it using Linq. Would I just be able to attribute my own classes and start writing Linq queries against my index??
Coordinator
Feb 27, 2009 at 5:41 AM
Hi Blacky,

"but does Linq to Lucene have any hard dependency on Linq to SQL"

No, not a hard dependency. The only component that uses Linq to SQL (System.Data.Linq.dll) is the DatabaseIndexSet. Everything else simply uses the System.Core.dll
You make it sound like LINQ to SQL is a bad dependency to keep. I don't think it's too bad, as it comes with v3.5 of the framework.

The base set class - IndexSet - allows you to construct indexes out of any classes that have the necessary attributes.

"I can see that there are methods for generating an index from a Linq2SQL data context, but is that the only relationship"

Yes. That's the only relationship. I wrote it for convenience. I still am yet to do the update/synch stuff (to be honest - I haven't needed it yet).

"The reason I ask is that I already have an index created using another method, but I'd quite like to query it using Linq. Would I just be able to attribute my own classes and start writing Linq queries against my index??"

What method have you used to create the index? If you have used the Lucene.Net classes yourself, unfortunately LINQ to Lucene can't use it (without adjusting the way it works) because LINQ to Lucene needs to manage the IndexWriter/Reader.

If you check out the trunk, Demo2 contains a good example of using poco+attributes without using LINQ to SQL.

Thanks for the questions, please don't hestitate to offer suggestions, feedback and comments - here and in the issue tracker.



Feb 27, 2009 at 7:02 PM
Thanks for your answer.

It's not that Linq to SQL is bad - actually I think it's great and when you dig into it it's a lot more flexible than it looks at first sight. My problem is that my index is created directly using Lucene.net. The reason I'm interested in Linq to Lucene is that I have some general purpose UI that is based on IQueryable collections and dynamically created Linq expressions. I'd like to re-use that to query my index and display the results. The index is created and maintained as records are added in a different part of the app, not using Linq to SQL.

From your answer it sounds like I would have to re-think the indexing approach if I were to use Linq to Lucene. This might be possible: I'll think it over...

Thanks again!
Feb 27, 2009 at 7:16 PM
So, I did think about it.

Looking at demo 2, it looks like if I attribute my POCO classes and switch to using your Index<T> to create and maintain the index I would then be able to query the index using Linq to Lucene. That should be feasible and not too much effort :o)

Time to stop theorising and give it a try...
Coordinator
Mar 2, 2009 at 10:17 AM
I once did things the old way of writing custom analyzers, formatters and indexing systems, but found an POCO decoration model fitted perfectly for rapidly creating indexes.\

For indexing databases, some people will still choose their full-text indexing of their db, but I believe there are many situations when having finer control of the index is better.

I'm in the middle of writing such a post that just uses POCO to create a location based search index.