-
MY PROJECTS
-
Recent Posts
- SQL.How can you compare two nullable values safely, and how does IS DISTINCT FROM differ from <>?
- SQL.How are NULL values ordered by ORDER BY, how do defaults differ between databases, and how can you control their placement?
- SQL.How does NULL propagate through arithmetic expressions, and how can COALESCE and NULLIF help handle missing values and division by zero?
- SQL.How does NULL affect join conditions, and why can filtering the right-hand table in WHERE remove unmatched rows from a LEFT JOIN?
- SQL.How do GROUP BY and DISTINCT treat NULL values, even though NULL = NULL evaluates to UNKNOWN?
- SQL.How do aggregate functions handle NULL, and what is the difference between COUNT(*), COUNT(column), and COUNT(DISTINCT column)?
- SQL.How does NULL affect IN and NOT IN, and why can NOT EXISTS be a safer choice when a subquery returns nullable values?
- SQL.How do WHERE, HAVING, and CHECK constraints treat conditions that evaluate to UNKNOWN?
- SQL.Why do column = NULL and column <> NULL not work as expected, and when should you use IS NULL and IS NOT NULL?
- SQL.What is SQL’s three-valued logic (TRUE, FALSE, UNKNOWN), and how do AND, OR, and NOT behave with UNKNOWN?
- ChromeDevTools.Watch all failed requests
- SQL.What are domain types (or constraints on data types), and how do they help enforce data correctness?
- SQL.How does SQL handle comparisons between different data types (for example, string vs number), and why is this dangerous?
- SQL.What is the difference between DATE, TIME, TIMESTAMP, and TIMESTAMPTZ, and which one should be used for business events?
- SQL.How do numeric types like INTEGER, BIGINT, DECIMAL, and FLOAT differ in terms of precision and use cases?
- SQL.What problems can arise from implicit type casting in SQL, and how can it affect indexes?
- SQL.How does NULL differ from 0, an empty string, or FALSE in SQL?
- SQL.What is the difference between CHAR, VARCHAR, and TEXT, and when would you choose each?
- SQL.What is MVCC ?
- SQL.What is AutoVacuum Postgres ?
Categories
- Aptana
- Azure
- C#
- DataSnap
- DBExpress
- Delphi
- Delphi и сети
- Delphi. Язык программирования
- ExtJS
- FastReport
- FireDAC
- FireMonkey
- GIT
- ICS
- IDE
- IIS
- Indy
- InnoSetup
- javascript
- jQuery
- JSON
- LiveBindings
- MSHTML
- MySQL
- PHP
- REST
- Ribbons
- SMS
- SQL инструкции
- SVN
- TRichView
- UniGui
- WebBroker
- WinAPI
- Windows
- Алгоритмы
- Без рубрики
- Деревья
- Ищу ответ
- Компонентостроение
- Мои компоненты
- Начальный уровень
- Обработка исключений
- Парсинг
- Потоки(Threads)
- Регулярные выражения
- Тестирование приложений
Category Archives: C#
C#. Shared assembly
Lets use Carlib.dll from One file Assembly 1. Strong name Properties – > Signing – > Sign the assembly -> New – > SomeName (for ex. myKeyPair.snk) 2. Install assembly to GAC (Global Assembly Cache) go to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio … Continue reading
Posted in C#
Comments Off on C#. Shared assembly
С#. Assembly theory
Assembly – versioned (for ex. 1.0.0.0), self described( has manifest, links to other external assemblies, info about all types) binary, supported by CLR (Common Language Runtime). One EXE is divided in may exe, dll files. Assembly defines type borders. Example. … Continue reading
Posted in C#
Comments Off on С#. Assembly theory
C#. Creating one file assembly. Example
Lets create CarLibrary.dll assembly File NewProject ClassLibrary
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CarLibrary { public enum EngineState {EngineAlive, engineDead} public abstract class Car { public string PetName { get; set; } public int CurrentSpeed { get; set; } public int MaxSpeed { get; set; } protected EngineState egnState = EngineState.EngineAlive; public EngineState EngineState {get { return egnState; }} public abstract void TurboBoost(); public Car(){} public Car(string name, int maxSp, int currSp) { PetName = name; MaxSpeed = maxSp; CurrentSpeed = currSp; } } } |
In other file Derived.cs 2 derived classes ClassView – addReference – System.Windows.Forms
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CarLibrary; using System.Windows.Forms; namespace CarLibrary { public class SportsCar : Car { public SportsCar() { } public SportsCar(string name, int maxSp, int currSp) : base(name, maxSp, currSp) { } public override void TurboBoost() { MessageBox.Show("Turbo Boost Sports Car"); } } public class MiniVan : Car { public MiniVan() { } public MiniVan(string name, int maxSp, int currSp) : base(name, maxSp, currSp) { } public override void TurboBoost() { MessageBox.Show("Turbo Boost MiniVan"); } } } |
Now lets create new project CarClient ClassView – addReference – Browse – CarLibrary.dll
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CarLibrary; namespace CarClient { class Program { static void Main(string[] args) { SportsCar viper = new SportsCar("Viper",240,40); viper.TurboBoost(); MiniVan mv = new MiniVan(); mv.TurboBoost(); Console.ReadLine(); } } } |
Posted in C#
Comments Off on C#. Creating one file assembly. Example
C#. Namespace examples
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MyShapes; using The3DHexagon=My3DShapes.Hexagon; // alias for class with same name namespace CustomNameSpace { class Program { static void Main(string[] args) { // one way Hexagon h = new Hexagon(); Circle c = new Circle(); Square s = new Square(); //another, no need to write using MyShapes MyShapes.Hexagon h1 = new Hexagon(); MyShapes.Circle c1 = new Circle(); MyShapes.Square s1 = new Square(); // The3DHexagon h2 = new The3DHexagon(); } } namespace someEmbedded { public class SomeClass { Hexagon h = new Hexagon(); } } } |
Circle.cs
|
1 2 3 4 5 6 7 8 9 10 11 12 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MyShapes { class Circle { } } |
Hexagon.cs
|
1 2 3 4 5 6 7 8 9 10 11 12 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MyShapes { class Hexagon { } } |
Square.cs
|
1 2 3 4 5 6 7 8 9 10 11 12 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MyShapes { class Square { } } |
Posted in C#
Comments Off on C#. Namespace examples
C#. Delegates, Func, Action
Ну, есть ключевое слово delegate — это описание сигнатуры функции, т. е., её списка параметров и типа возвращаемого значения. Используется так:
|
1 |
public delegate bool MyPredicate(int x); |
Им можно пользоваться так:
|
1 2 3 4 5 6 7 8 9 10 |
private bool IsOdd(int i) { return i % 2 != 0; } private Analyze(MyPredicate p, int x) { bool result = p(x); if (result) Console.WriteLine("found!"); } Analyze(IsOdd, 1); // печатает "found!" |
С другой стороны, есть готовые, предопределённые сигнатуры функций (Func<TArg1, TArg2, …, TResult> с возвращаемым … Continue reading
Posted in C#
Comments Off on C#. Delegates, Func, Action
C#. Func template for delegates
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FuncExample { // what is Func - is prepared delegate - no need to define own delegate class Program { static void Main(string[] args) { Calc c = new Calc(); Console.WriteLine(c.Execute(Add,1,2)); Console.ReadLine(); } public static double Add(int a1, int a2) { return a1 + a2; } } class Calc { public double Execute(Func<int,int, double> function, int arg1, int arg2) { return function(arg1,arg2); } } } |
Posted in C#
Comments Off on C#. Func template for delegates
C#. Syntax simple examples
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BasicLinqSyntax { class Program { static void Main(string[] args) { ProductInfo[] itemsInStock = //new[] { new ProductInfo {Name="Mac's Coffee", Description="CoffeeWithTeeth",NumberInStock=24 }, new ProductInfo {Name="Milk Maid Milk", Description="Milk cows love",NumberInStock=100 }, new ProductInfo {Name="Pure Silk Tofu", Description="Bland is Possible",NumberInStock=120 }, new ProductInfo {Name="CruchyPops", Description="Cheesy, peppery goodness",NumberInStock=2 }, new ProductInfo {Name="Rip Off Water", Description="From the Tap to Your vallet",NumberInStock=100 }, new ProductInfo {Name="Classic Valpo Pizza", Description="Everyone loves pizza",NumberInStock=73 } }; SelectEveryThing(itemsInStock); SelectProductNames(itemsInStock); SelectWhereExample(itemsInStock); ProectionOfNewDataType(itemsInStock); GetCountFromQuery(itemsInStock); OrderByQuery(itemsInStock); Array objs = ProectionOfNewDataTypeReturn(itemsInStock); // with return foreach (object o in objs) { Console.WriteLine(o); } DisplayDiff(); DisplayInterSection(); DisplayUnion(); DisplayConcat(); DisplayConcatDistinct(); Console.ReadLine(); } static void SelectEveryThing(ProductInfo[] products) { Console.WriteLine("select all"); var all = from p in products select p; foreach (var p in all) Console.WriteLine(p); Console.WriteLine(" "); } static void SelectProductNames(ProductInfo[] products) { Console.WriteLine("Only product names:"); var names = from p in products select p.Name; foreach (var p in names) Console.WriteLine(p); Console.WriteLine(" "); } static void SelectWhereExample(ProductInfo[] products) { Console.WriteLine("SelectWhereExample:"); var subset = from p in products where p.NumberInStock > 25 && p.Name.Length > 10 select p; foreach (var p in subset) Console.WriteLine(p); Console.WriteLine(" "); } static void ProectionOfNewDataType(ProductInfo[] products) { Console.WriteLine("ProectionOfNewDataType - will create new objects:"); var subset = from p in products select new { p.Name, p.Description }; foreach (var p in subset) Console.WriteLine(p); // return subset; // << will not compile Console.WriteLine(" "); } static Array ProectionOfNewDataTypeReturn(ProductInfo[] products) { Console.WriteLine("ProectionOfNewDataTypeReturn - will create new objects:"); var subset = from p in products select new { p.Name, p.Description }; foreach (var p in subset) Console.WriteLine(p); Console.WriteLine(" "); return subset.ToArray(); // << will not compile } static void GetCountFromQuery(ProductInfo[] products) { int count = (from p in products select p).Count<ProductInfo>(); Console.WriteLine("Count in query = " + count); Console.WriteLine(" "); } static void ReverseSubsetQuery(ProductInfo[] products) { Console.WriteLine("select all and reverse"); var all = from p in products select p; foreach (var p in all.Reverse()) Console.WriteLine(p); Console.WriteLine(" "); } static void OrderByQuery(ProductInfo[] products) { Console.WriteLine("OrderBy Query"); var all = from p in products orderby p.Name ascending select p; foreach (var p in all.Reverse()) Console.WriteLine(p); Console.WriteLine(" "); } static void DisplayDiff() { List<string> myCars = new List<string>() { "Yugo", "Aztec", "BMW" }; List<string> yourCars = new List<string>() { "BMW", "SAAB", "Aztec" }; var carDiff = (from c in myCars select c).Except(from c2 in yourCars select c2); Console.WriteLine("Here is what you don't have but I do:"); foreach (var s in carDiff) Console.WriteLine(s); } static void DisplayInterSection() { List<string> myCars = new List<string>() { "Yugo", "Aztec", "BMW" }; List<string> yourCars = new List<string>() { "BMW", "SAAB", "Aztec" }; var carIntersect = (from c in myCars select c).Intersect(from c2 in yourCars select c2); Console.WriteLine("Here is what we have in intersection:"); foreach (var s in carIntersect) Console.WriteLine(s); } static void DisplayUnion() { List<string> myCars = new List<string>() { "Yugo", "Aztec", "BMW" }; List<string> yourCars = new List<string>() { "BMW", "SAAB", "Aztec" }; var carUnion = (from c in myCars select c).Union(from c2 in yourCars select c2); Console.WriteLine("Here is what we have in Union:"); foreach (var s in carUnion) Console.WriteLine(s); } static void DisplayConcat() { List<string> myCars = new List<string>() { "Yugo", "Aztec", "BMW" }; List<string> yourCars = new List<string>() { "BMW", "SAAB", "Aztec" }; var carConcat = (from c in myCars select c).Concat(from c2 in yourCars select c2); Console.WriteLine("Here is what we have in Concat:"); foreach (var s in carConcat) Console.WriteLine(s); } static void DisplayConcatDistinct() { List<string> myCars = new List<string>() { "Yugo", "Aztec", "BMW" }; List<string> yourCars = new List<string>() { "BMW", "SAAB", "Aztec" }; var carConcat = (from c in myCars select c).Concat(from c2 in yourCars select c2); Console.WriteLine("Here is what we have in ConcatDistinct:"); foreach (var s in carConcat.Distinct()) Console.WriteLine(s); } static void AggregateOps() { double[] winterTemps = { 2.0, -21.3, 8, -4, 0, 8.2 }; Console.WriteLine("Max temp is {0}", (from t in winterTemps select t).Max()); Console.WriteLine("Min temp is {0}", (from t in winterTemps select t).Min()); Console.WriteLine("Average temp is {0}", (from t in winterTemps select t).Average()); Console.WriteLine("Sum temp is {0}", (from t in winterTemps select t).Sum()); } } class ProductInfo { public string Name { get; set; } public string Description { get; set; } public int NumberInStock { get; set; } public override string ToString() { return string.Format("Name={0},Description={1},Number in Stock={2}", Name, Description, NumberInStock); } } } |
Posted in C#
Comments Off on C#. Syntax simple examples
C#.OfTypeAsFilter
Non generic collections may have different stuff, we can filter them
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Linq.FiltrationWithOfType { class Program { static void Main(string[] args) { OfTypeAsFilter(); Console.ReadLine(); } static void OfTypeAsFilter() { ArrayList myStuff = new ArrayList(); myStuff.AddRange(new object[] { 10, 400, 8, false, new object(), "string data" } ); var myInts = myStuff.OfType<int>(); // will filter only ints foreach (var i in myInts) Console.WriteLine(i); } } } |
Posted in C#
Comments Off on C#.OfTypeAsFilter
C#. Linq and Non generic collections, using OfType
Main idea is to use OfType<T> to cast to generic variant
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
using System; using System.Collections.Generic; using System.Collections; // << non generic using System.Linq; using System.Text; using System.Threading.Tasks; namespace LinqAndNonGenericCollections { class Program { static void Main(string[] args) { LinqOverArrayList(); Console.ReadLine(); } static void LinqOverArrayList() { ArrayList cars = new ArrayList() // << non generic { new Car {PetName="BMW",Color="1234",Speed=10,Make=123456 }, new Car {PetName="Lada",Color="1234",Speed=20,Make=123456 }, new Car {PetName="Mitsubishi",Color="1234",Speed=30,Make=123456 }, new Car {PetName="Ferrari",Color="1234",Speed=40,Make=123456 } }; // transform ArrayList in type compatible to IEnumerable<T> var carsEnum = cars.OfType<Car>(); // <<< !!! var fastCars = from c in carsEnum where c.Speed > 20 select c; foreach (var car in fastCars) { Console.WriteLine(car.PetName); } } } class Car { public string PetName { get; set; } public string Color { get; set; } public int Speed { get; set; } public int Make { get; set; } } } |
Posted in C#
Comments Off on C#. Linq and Non generic collections, using OfType
C#. LinqAndCollections
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LinqAndCollections { class Program { static void Main(string[] args) { List<Car> Cars = new List<Car>() { new Car {PetName="BMW",Color="1234",Speed=10,Make=123456 }, new Car {PetName="Lada",Color="1234",Speed=20,Make=123456 }, new Car {PetName="Mitsubishi",Color="1234",Speed=30,Make=123456 }, new Car {PetName="Ferrari",Color="1234",Speed=40,Make=123456 } }; GetFastCars(Cars); Console.WriteLine(" "); GetFastFerrari(Cars); Console.ReadLine(); } static void GetFastCars(List<Car> Cars) { var fastCars = from c in Cars where c.Speed > 20 select c; foreach (var car in fastCars) Console.WriteLine(car.PetName); } static void GetFastFerrari(List<Car> Cars) { var fastCarsBMW = from c in Cars where c.Speed > 20 && c.PetName == "Ferrari" select c; foreach (var car in fastCarsBMW) Console.WriteLine(car.PetName); } } class Car { public string PetName { get; set; } public string Color { get; set; } public int Speed { get; set; } public int Make { get; set; } } } |
Posted in C#
Comments Off on C#. LinqAndCollections