LinqToSolr – use LINQ to obtain data from Solr

Due to the fact that in my company, Solr was chosen as a full-text search platform, there appeared a strong desire to simplify the work with Solr queries using LINQ expressions.

Having surfed the Internet for alternatives, I came to the conclusion that at the moment I do not have the required library to be publicly available. The maximum I managed to find is a very partial implementation of Solr.NET queries (and the skeptic comment of the author himself).

(more…)

Functional C#

C# is a multi-paradigm programming language. Recently, the course has been set towards new functional constructions in C#. We can go further and add other extension methods that allow writing less code without ‘climbing’ in the F# territory.

(more…)

CombGuid: Generation of SQL Server-friendly Guid Values in .NET Applications

Usage of UUID as a primary key for tables has a bunch of pros, including the option to retrieve IDs for objects created in a client application on its own without calls to the database server. However, usage of UUID as a primary key has a con: GUIDs generated by the client application may be not quite SQL Server-friendly that can lead to the overhead during the addition of a new record. (more…)

Comparing Objects by Value. Part 6: Structure Equality Implementation

We have already analyzed peculiarities of structs of the .NET framework that represent Value Types when comparing objects by value – instance of structs.

Now, I am going to describe this process on a particular example to check whether it will allow us to determine the use of the object comparison by value in general and thus, to simplify a sample of comparing objects by value – class instances that represent reference types.

(more…)

Comparing Objects by Value. Part 1. Beginning

It is a common fact that the .NET object model, as well as other software program platforms, allow comparing objects by reference and by value.

By default, two objects are equal if the corresponding object variables have the same reference. Otherwise, they are different.

However, in some cases, you may need to state that two objects belonging to the same class are equal if their content match in a certain way.

Assume we have the Person class, which contains some personal data – First Name, Last Name, and Birth date.

Consider the following points:

  1. What is the minimum required number of class modifications to assure comparing class objects by values with the help of the standard .NET architecture?
  2. What is the minimum required number of class modifications to assure comparing class objects by values (every time, if not explicitly stated that objects may be compared by a reference) with the help of the standard .NET architecture?

For each case, we will see the best way to compare objects by value to get a consistent, compact, copy-paste free, and productive code. It is not as trivial as it may seem for the first time.

(more…)

Sorting in .NET

Sorting is a typical task each programmer should be aware of. That’s why this article is dedicated to the implementation of sorting in .NET. I will describe how array sorting works in .NET, its aspects, and make a small comparison with sorting in Java.

Let’s begin with the fact that the first versions of .NET use the quicksort algorithm by default. So, let’s consider pros and cons of the quicksort.

Pros

  1. One of the most high-performance algorithms(on a practical level) of general-purpose internal sorting.
  2. Easy implementation.
  3. Requires just O(logn) of additional memory for its operation.
  4. Can be easily combined with cashing and internal memory mechanisms.

(more…)