-
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#.StackOnOneLinkedList
Git
|
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 |
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StackOnOneLinkedList { class Program { static void Main(string[] args) { // fill stack with Count elements int Count = 10; CustomStackLinkedList<string> stack = new CustomStackLinkedList<string>(); //FixedGenericsStack<string> stack = new FixedGenericsStack<string>(Count); Random r = new Random(); Console.WriteLine("lets fill stack with Count elements"); for (int i = 0; i < Count; i++) { int someRandomNumber = r.Next(100); stack.push(someRandomNumber.ToString()); } // iterator foreach (var s in stack) { Console.WriteLine(s.ToString()); } Console.WriteLine("What size of stack now?"); Console.WriteLine(stack.size()); Console.WriteLine("lets take last 5 elements from stack"); for (int i = 0; i < 5; i++) { Console.WriteLine(stack.pop()); } Console.WriteLine("What size of stack now?"); Console.WriteLine(stack.size()); Console.WriteLine("If stack isEmpty?"); if (stack.isEmpty()) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadLine(); } } class CustomStackLinkedList<T> : IEnumerable<T> { Node<T> first; private int N; class Node<T> { public T item; public Node<T> next; } public bool isEmpty() { return (first == null) || (N == 0); } public int size() { return N; } public void push(T item) { // adding to the begining Node<T> oldfirst = first; first = new Node<T>(); first.item = item; first.next = oldfirst; N++; } public T pop() { T item = first.item; first = first.next; N--; return item; } /* IEnumerator IEnumerable.GetEnumerator() { //throw new NotImplementedException(); } */ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } public IEnumerator<T> GetEnumerator() { var node = first; while (node != null) { yield return node.item; node = node.next; } } } } |
Posted in C#
Comments Off on C#.StackOnOneLinkedList
C#. OneLinkedList
Example
|
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SimpleAdjListExample { class Program { static void Main(string[] args) { Node<string> first = new Node<string>(); Node<string> second = new Node<string>(); Node<string> third = new Node<string>(); first.item = "to"; second.item = "be"; third.item = "or"; first.next = second; second.next = third; // insert to begin of list Node<string> oldfirst = first; first = new Node<string>(); first.item = "not"; first.next = oldfirst; //delete from begin first = null; //insert to the end Node<string> oldlast = third; third = new Node<string>(); third.item = "some item"; // traverse for (Node<string> x = first; x != null; x = x.next) { x.item = "someValue"; } } } public class Node<T> { public T item; public Node<T> next; } } |
Posted in C#
Comments Off on C#. OneLinkedList
C#.Algo.StackOnLinkedList
Git
|
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 |
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StackOnOneLinkedList { class Program { static void Main(string[] args) { // fill stack with Count elements int Count = 10; CustomStackLinkedList<string> stack = new CustomStackLinkedList<string>(); //FixedGenericsStack<string> stack = new FixedGenericsStack<string>(Count); Random r = new Random(); Console.WriteLine("lets fill stack with Count elements"); for (int i = 0; i < Count; i++) { int someRandomNumber = r.Next(100); stack.push(someRandomNumber.ToString()); } // iterator foreach (var s in stack) { Console.WriteLine(s.ToString()); } Console.WriteLine("What size of stack now?"); Console.WriteLine(stack.size()); Console.WriteLine("lets take last 5 elements from stack"); for (int i = 0; i < 5; i++) { Console.WriteLine(stack.pop()); } Console.WriteLine("What size of stack now?"); Console.WriteLine(stack.size()); Console.WriteLine("If stack isEmpty?"); if (stack.isEmpty()) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadLine(); } } class CustomStackLinkedList<T> : IEnumerable<T> { Node<T> first; private int N; class Node<T> { public T item; public Node<T> next; } public bool isEmpty() { return (first == null) || (N == 0); } public int size() { return N; } public void push(T item) { // adding to the begining Node<T> oldfirst = first; first = new Node<T>(); first.item = item; first.next = oldfirst; N++; } public T pop() { T item = first.item; first = first.next; N--; return item; } /* IEnumerator IEnumerable.GetEnumerator() { //throw new NotImplementedException(); } */ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } public IEnumerator<T> GetEnumerator() { var node = first; while (node != null) { yield return node.item; node = node.next; } } } } |
Posted in C#
Comments Off on C#.Algo.StackOnLinkedList
С#. Algo. FixedStack
Git
|
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FixedStack { class Program { static void Main(string[] args) { // fill stack with Count elements int Count = 10; //FixedCapacityStackOfStrings s = new FixedCapacityStackOfStrings(Count); FixedGenericsStack<string> s = new FixedGenericsStack<string>(Count); Random r = new Random(); Console.WriteLine("lets fill stack with Count elements"); for (int i = 0; i < Count; i++) { int someRandomNumber = r.Next(100); s.push(someRandomNumber.ToString()); Console.WriteLine(someRandomNumber); } Console.WriteLine("What size of stack now?"); Console.WriteLine(s.size()); Console.WriteLine("lets take last 5 elements from stack"); for (int i = 0; i < 5; i++) { Console.WriteLine(s.pop()); } Console.WriteLine("What size of stack now?"); Console.WriteLine(s.size()); Console.WriteLine("If stack isEmpty?"); if (s.isEmpty()) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadLine(); } } class FixedCapacityStackOfStrings { private string[] a; public int N; public FixedCapacityStackOfStrings(int ACapacity) { a = new string[ACapacity]; } public bool isEmpty() { return N == 0; } public int size() { return N; } public void push(string item) { a[N++] = item; } public string pop() { return a[--N]; } } class FixedGenericsStack<T> { private T[] a; public int N; public FixedGenericsStack(int ACapacity) { a = new T[ACapacity]; } public bool isEmpty() { return N == 0; } public int size() { return N; } public void push(T item) { a[N++] = item; } public T pop() { return a[--N]; } } } |
Posted in C#
Comments Off on С#. Algo. FixedStack
С#. Algo. BinarySearch
Git Recusive, Non Recursive, Generic, Non Generic binary search
|
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BinarySearch { class Program { static void Main(string[] args) { Random r = new Random(); //int[] a = new int[100]; //for (int i = 0; i < 100; i++) a[i] = r.Next(100); int[] a = { 1, 3, 5, 6, 12,30,40,55,16,18,20 }; //int[] a = { 1, 5, 3 }; Array.Sort(a); if (BinarySearch(5, a) != -1) Console.WriteLine("Non recursive BS: Element found"); if (BinarySearchGeneric<int>(5, a) != -1) Console.WriteLine("Non recursive Generic BS: Element found"); if (BinarySearchRecursive(5, a, 0, a.Length) != -1) Console.WriteLine("Recursive BS: Element found"); if (BinarySearchRecursiveGeneric<int>(5, a, 0, a.Length) != -1) Console.WriteLine("Recursive Generic BS: Element found"); Console.ReadLine(); } static int BinarySearch(int key, int[] a) { int low = 0; int hi = a.Length - 1; while (low <= hi) { int mid = (low + hi) / 2; if (key < a[mid]) hi = mid - 1; else if (key > a[mid]) low = mid + 1; else return mid; } return -1; } public static int BinarySearchRecursive(int key, int[] a, int lo, int hi) { if (hi < lo) return lo; int mid = lo + (hi - lo) / 2; if (key < a[mid]) return BinarySearchRecursive(key, a, lo, mid - 1); else if (key > a[mid]) return BinarySearchRecursive(key, a, mid + 1, hi); else return mid; } static int BinarySearchGeneric<T>(T key, int[] a) where T : IComparable { int low = 0; int hi = a.Length - 1; while (low <= hi) { int mid = (low + hi) / 2; int cmp = key.CompareTo(a[mid]); if (cmp < 0) { hi = mid - 1; } else if (cmp > 0) { low = mid + 1; } else return mid; } return -1; } public static int BinarySearchRecursiveGeneric<T>(T key, int[] a, int lo, int hi) where T : IComparable { // if (hi < lo) return lo; int mid = lo + (hi - lo) / 2; int cmp = key.CompareTo(a[mid]); if (cmp < 0) { return BinarySearchRecursiveGeneric(key, a, lo, mid - 1); } else if (cmp > 0) { return BinarySearchRecursiveGeneric(key, a, mid + 1, hi); } else return mid; } } } |
Posted in C#
Comments Off on С#. Algo. BinarySearch
C#. Algorithms. Greatest common divisor
Git
|
1 2 3 4 5 6 |
public static int gcd(int p, int q) { if (q == 0) return p; int r = p % q; return gcd(q, r); } |
Posted in C#
Comments Off on C#. Algorithms. Greatest common divisor
C#. Connection string examples
localdb examples
|
1 2 3 4 |
<connectionStrings> <add name ="DBConnection" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=userstore.mdf;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False; " providerName="System.Data.SqlClient" /> </connectionStrings> |
With attachment, from ASP MVC, file will be saved in AppData dir
|
1 2 3 4 |
<connectionStrings> <add name="BookContext" connectionString="Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename='|DataDirectory|\Bookstore.mdf';Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> |
ms sql server example #1
|
1 2 3 4 |
<connectionStrings> <add name="BookContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Bookstore;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> |
#2
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<connectionStrings> <add name ="DBConnection" connectionString=" Data Source=DESKTOP-T9U6IEP\SQLEXPRESS; Initial Catalog=userstore.mdf; Integrated Security=True; Connect Timeout=15; Encrypt=False; TrustServerCertificate=True; ApplicationIntent=ReadWrite; MultiSubnetFailover=False; " providerName="System.Data.SqlClient" /> </connectionStrings> |
Posted in C#
Comments Off on C#. Connection string examples
C#. Entity. CodeSecondApproach
If db already exists and filled with data we just can create Entities in code… For example lets create db manually… in localdb of SQL Server View->Server Explorer. Next in serverName type “(localdb)\MSSQLLocalDB” for vs 2015 and choose new datebase … Continue reading
Posted in C#
Comments Off on C#. Entity. CodeSecondApproach
С#. LocalDB adventure
just open cmd and type SqlLocalDB.exe start MSSQLLocalDB What is localDB? ProblemAndDecision Decision In Visual Studio 2012 all I had to do was enter:
|
1 2 |
(localdb)\v11.0 |
or Visual Studio 2015 changed to:
|
1 2 |
(localdb)\MSSQLLocalDB |
as the server name when adding a Microsoft SQL Server … Continue reading
Posted in C#
Comments Off on С#. LocalDB adventure
C#. Entity. Инициализация базы данных
Если нам необходимо, чтобы при первом обращении база данных уже была заполнена некоторыми начальными значениями, то мы можем произвести ее инициализацию. Инициализация происходит при первом обращении к контексту данных. Для инициализации мы можем использовать один из классов инициализаторов, которые имеются … Continue reading
Posted in C#
Comments Off on C#. Entity. Инициализация базы данных