Functional F# that slowly appears in C#

Functional F# that slowly appears in C#
Rate this post

For some reason, we often do not use this functionality. Maybe we haven’t got used to it yet. And sometimes we use it, having no idea that this is the functionality from F#.

Before reviewing it, let’s quickly run through the most interesting features that appeared in different versions of the language. Note that each time a new version of the language comes out with a new version of Visual Studio. For someone, this may be obvious, but even for developers who have worked with C# for several years, this may turn out to be a piece of news (not everyone takes notice of it).

Read More

Using Expressions to Filter Data of Database

Using Expressions to Filter Data of Database
Rate this post

I would like to start with a description of the problem that I encountered. There are entities in the database that need to be displayed as tables on the UI. The Entity Framework is used to access the database. There are filters for these table columns.

It is necessary to write a code to filter entities by parameters.

For example, there are two entities: User and Product.

Read More

Entity Framework: (anti)pattern Repository

Entity Framework: (anti)pattern Repository
4 (80%) 1 vote

A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Client objects construct query specifications declaratively and submit them to Repository for satisfaction.

Entity Framework provides us with the actual implementation of the Repository patterns: DbSet<T> and UnitOfWork: DbContext. I often see colleagues using in projects their own implementation of repositories on top of the ones existing in Entity Framework.

Read More

Working with SQL Server in Hybrid Cloud Scenarios. Part 2

Working with SQL Server in Hybrid Cloud Scenarios. Part 2
Rate this post

As a rule, impersonal information is stored in a public cloud, and the personalized part – in a private cloud. The question thus arises – how to combine both parts to return a single result at a user’s request? Suppose there is a table of customers divided vertically. The depersonalized columns were included in the table located in Windows Azure SQL Database, and columns with sensitive information (e.g., full name) remained in the local SQL Server. Both tables must be linked by the CustomerID key. Because they are located in different databases on different servers, the JOIN statement will not work. As a possible solution, we have considered the scenario, when the linkage was implemented on the local SQL Server. It served as a kind of entry point for the applications, and the cloud-based SQL Server was set up on it as a linked server. In this article, we will consider the case when both, the local and cloud servers, are equal in terms of the application, and the data merging occurs directly in it, i.e. at the business logic level.

Read More

LinqToSolr – use LINQ to obtain data from Solr

LinqToSolr – use LINQ to obtain data from Solr
Rate this post

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).

Read More

Functional C#

Functional C#
Rate this post

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.

Read More

Eliminating Duplication of Where Expressions in Application

Eliminating Duplication of Where Expressions in Application
Rate this post

Assume you have products and categories. A client says that it is necessary to use other business processes for the categories with the rating value higher than 50. You have a solid experience and you understand that tomorrow this value may be different – 127.37. As you want to avoid this situation, you write the code in the following way:

Read More