Lucene tutorial
Lucene.net is a open source text search engine library, ported from Lucene Java project.
Simone Chiaretta has publised a post series to learn more.
You man also interested in my other posts:
LINQ: Building an IQueryable provider series
LINQ: Building an IQueryable provider series
Here’s a list of all the posts in the building an IQueryable provider series. If you want to get the latest and greatest source code just follow that last link. If you want to discover how to build your own IQueryable provider read from the beginning. It is sort of like a tutorial.
Part I – Reusable IQueryable base classes
Part II – Where and reusable Expression tree visitor
Part II – Local variable references
Part IV – Select
Part V – Improved Column binding
Part VI – Nested queries
Part VII – Join and SelectMany
Part VIII – OrderBy
Part IX – Removing redundant subqueries
Part X – GroupBy and Aggregates
Part XI – More of everything
Part XII – Relationships and the IQ Toolkit
Part XIII – Updates and Batch Processing
Part XIV – Mapping and Providers
Part XV – Transactions, Sessions and Factories
Part XVI – Performance and CachingThe source code found in this series is also available at CodePlex.
http://www.codeplex.com/IQToolkit
The Wayward WebLog : LINQ: Building an IQueryable provider series
Moq with Linq Query Expression
Before
After
Yes, it’s gonna be largely a matter of personal style and preference, just like many prefer invoking
.Where(…)and.Select(…)instead offrom…where…select.
LINQ to FQL (Facebook Query Language)
LINQ to FQL is an open source project, sources, binaries and samples can be found at CodePlex. This library extends the Facebook Developer Toolkit.
Introduction
This library enables developers to use LINQ (.NET Language-Integrated Query) with Facebook instead of string based FQL queries. The main benefits for using this library are:
- Type safety: queries are now typed and their syntax is verified during compilation.
- Auto-complete now function when composing queries in Visual Studio.
- Using Facebook / anonymous objects for query results.
Example: this following sample code retrieves the names and pictures of all of your friends.
var db = new FacebookDataContext(); var friendIDs = from friend in db.friend_info where friend.uid1 == db.uid select friend.uid2; var friendDetails = from user in db.user where friendIDs.Contains(user.uid) select new { Name = user.name, Picture = user.pic_small };
Via CodeProject: LINQ to FQL (Facebook Query Language). Free source code and programming help
LINQ “Any” Keyword to check for existence of an element/attribute
One of the things you must do when writing a LINQ to Xml query definition is check for the existence of nonrequired elements and attributes before using them. For instance, a client application displays an image of the book in the ListBox control. The source URL of the image is grabbed from the SmallImage element’s URL element. If the SmallImage element does not exist, which is certainly a possibility if there is no image on record, the LINQ query definition must account for this.
For example,
<Item>
<SmallImage>
<URL>
http://www.silverlight-data.com/images/someImage.png
</URL>
</SmallImage>
</Item>
Before grabbing a value, you can perform a simple check to make sure the element exists; you do this by checking the Elements collection’s Any method. The Any method returns a Boolean value that indicates whether the collection contains elements. If the element exists, you can grab the value of the element. If the element does not exist you can set alternatives. The following shows the logic that checks for the existence of the image’s URL; if it is found it grabs the value and sets it to the imageSource variable.
let imageSource = (book.Elements(ns + "SmallImage").Any() ? book.Element(ns + "SmallImage").Element(ns + "URL").Value : string.Empty)
p.s. for more on the usage of the keyword let, take a look at http://vincenthomedev.wordpress.com/2007/12/19/linq-let-keyword/
LINQ Dynamic Query – Strongly Typed Way
In .NET 3.5 there is a System.Linq.Dynamic namespace which allows you to use string expressions in LINQ queries. It can be used to create dynamic queries but I don’t like it because it is not type-safe. So let me give you an introduction to anonymous functions, lambda expression trees and the PredicateBuilder class. These features can be used to create finder methods which can use dynamic strong-typed where-clauses as input parameters.
LINQ Dynamic Query Library
Example
Instead of using language operators or type-safe lambda extension methods to construct your LINQ queries, the dynamic query library provides you with string based extension methods that you can pass any string expression into.
For example,
![]()
Using the LINQ DynamicQuery library I could re-write the above query expression instead like so:
![]()
Notice how the conditional-where clause and sort-orderby clause now take string expressions instead of code expressions. Because they are late-bound strings I can dynamically construct them. For example: I could provide UI to an end-user business analyst using my application that enables them to construct queries on their own (including arbitrary conditional clauses).
Download Dynamic Query Library & Documentation
C# Dynamic Query Library (included in the \LinqSamples\DynamicQuery directory)
You can copy/paste either the C# or VB implementations of the DynamicQuery library into your own projects and then use it where appropriate to more dynamically construct LINQ queries based on end-user input.
Via Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) – ScottGu’s Blog
A List of LINQ Providers
LINQ Providers
- LINQ to Amazon
- LINQ to Active Directory
- LINQ to Bindable Sources (SyncLINQ)
- LINQ over C# project
- LINQ to CRM
- LINQ To Geo – Language Integrated Query for Geospatial Data
- LINQ to Excel
- LINQ to Expressions (MetaLinq)
- LINQ Extender (Toolkit for building LINQ Providers)
- LINQ to Flickr
- LINQ to Google
- LINQ to Indexes (LINQ and i40)
- LINQ to IQueryable (Matt Warren on Providers)
- LINQ to JSON
- LINQ to NHibernate
- LINQ to JavaScript
- LINQ to LDAP
- LINQ to LLBLGen Pro
- LINQ to Lucene
- LINQ to Metaweb(freebase)
- LINQ to MySQL, Oracle and PostgreSql (DbLinq)
- LINQ to NCover
- LINQ to Opf3
- LINQ to Parallel (PLINQ)
- LINQ to RDF Files
- LINQ to Sharepoint
- LINQ to SimpleDB
- LINQ to Streams
- LINQ to WebQueries
- LINQ to WMI
- LINQ to XtraGrid
Via http://blogs.msdn.com/charlie/archive/2006/10/05/Links-to-LINQ.aspx
LINQ to SQL vs LINQ to Entities
When Do I Use LINQ to SQL?
The primary scenario for using LINQ to SQL is when building applications with a rapid development cycle and a simple one-to-one object to relational mapping against the Microsoft SQL Server family of databases. In other words, when building an application whose object model is structured very similarly to the existing database structure, or when a database for the application does not yet exist and there is no predisposition against creating a database schema that mirrors the object model; you can use LINQ to SQL to map a subset of tables directly to classes, with the required columns from each table represented as properties on the corresponding class. Usually in these scenarios, the database has not and/or will not be heavily normalized.
When do I use LINQ to Entities?
The primary scenario targeted by LINQ to Entities is a flexible and more complex mapping scenario, often seen in the enterprise, where the application is accessing data stored in Microsoft SQL Server or other-third party databases.
In other words, the database in these scenarios contains a physical data structure that could be significantly different from what you expect your object model to look like. Often in these scenarios, the database is not owned or controlled by the application developer(s), but rather owned by a DBA or other third party, possibly preventing application developers from making any changes to the database and requiring them to adapt quickly to database changes that they may not have been aware of.
