.net, C# and programming

Any() vs Count: part 2

In Part 1, we compared Any() and Count methods for different collections and proposed optimization approaches.

Read more...

Any() vs Count: часть 2

В первой части мы сравнивали методы Any() и Count для различных коллекций и предложили вариант оптимизаций. Прошло достаточно времени, чтобы провести повторное сравнение.

Read more...

nvarchar(max) vs nvarchar(N)

MS SQL Server offers several data types for storing strings. The most popular are nvarchar(N) (1 ≤ N ≤ 4000) and nvarchar(max), which allow storing Unicode-encoded string data. Application developers often transfer their experience with the string type from programming languages like C# or Java to databases and automatically choose nvarchar(max), which can store strings up to 2GB. However, databases store and process data in fundamentally different ways. In this article, I will explain and demonstrate the consequences of unjustified use of the nvarchar(max) type.

Read more...

nvarchar(max) vs nvarchar(N)

MS SQL Server предоставляет нам на выбор несколько типов данных для хранения строк. Самый популярный - nvarchar(N) (где 1 ≤ N ≤ 4000) или nvarchar(max), который позволяет хранить строковые данные в кодировке Юникод. При этом, часто прикладные разработчики переносят опыт использования типа string из языка приложения (C# или Java, например) в базы данных и не задумываясь выбирают тип nvarchar(max), позволяющий хранить строки размером до 2ГБ. Но базы данных хранят и работают с данными совершенно другим способом. В этой статье я расскажу и покажу на практике, к чему может приводить неоправданное использование типа nvarchar(max).

Read more...

List initializer

We all used to type new List<int> { 1, 2, 3, 4 } or new int[] { 1, 2, 3, 4} to initialize collections with some values. It looks similar in syntax but differs in behavior, and you should be careful if you are concerned about performance.

Read more...