Friday, November 26, 2021

Delete duplicate records in sql

 WITH CTE AS(

   SELECT [col1], [col2], [col3], [col4], 
       ROW_NUMBER()OVER(PARTITION BY col1 ORDER BY col1) as RN
   FROM dbo.Table1
)
DELETE FROM CTE WHERE RN > 1

Friday, April 16, 2021

Difference between Array and ArrayList

 

Difference between Array and ArrayList


The following table lists the differences between Array and ArrayList in C#.

ArrayArrayList
Must include System namespace to use array.Must include System.Collections namespace to use ArraList.
Array Declaration & Initialization:
int[] arr = new int[5]
int[] arr = new int[5]{1, 2, 3, 4, 5};
int[] arr = {1, 2, 3, 4, 5};
ArrayList Declaration & Initialization:
ArrayList arList = new ArrayList();
arList.Add(1);
arList.Add("Two");
arList.Add(false);
Array stores a fixed number of elements. The size of an Array must be specified at the time of initialization.ArrayList grows automatically and you don't need to specify the size.
Array is strongly typed. This means that an array can store only specific type of items\elements.ArrayList can store any type of items\elements.
No need to cast elements of an array while retrieving because it is strongly typed and stores a specific type of items only.The items of ArrayList need to be cast to an appropriate data type while retrieving. So, boxing and unboxing happens.
Performs faster than ArrayList because it is strongly typed.Performs slows because of boxging and unboxing.
Use static helper class Array to perform different tasks on the array.ArrayList itself includes various utility methods for various tasks.

Difference between Hashtable and Dictionary

 

Difference between Hashtable and Dictionary


The following table lists the differences between Hashtable and Dictionary in C#.

HashtableDictionary
Hashtable is included in the System.Collections namespace.Dictionary is included in the System.Collections.Generic namespace.
Hashtable is a loosely typed (non-generic) collection, this means it stores key-value pairs of any data types.Dictionary is a generic collection. So it can store key-value pairs of specific data types.
Hashtable is thread safe.Only public static members are thread safe in Dictionary.
Hashtable returns null if we try to find a key which does not exist.Dictionary throws an exception if we try to find a key which does not exist.
Data retrieval is slower than dictionary because of boxing-unboxing.Data retrieval is faster than Hashtable.

IEnumerable vs ICollection vs IList vs IQueryable in C#

 

IEnumerable vs ICollection vs IList vs IQueryable in C#


In C#, we have been using collections like IEnumerable, ICollection, IList interchangeably but do you really know what is it that separates each other.

They all have specific characteristics that differentiate them and makes them adaptable to certain scenarios.

All of the above holds a list maintaining the order of items but which one should we use and in which case, let’s see.

IEnumerable vs ICollection vs IList vs IQueryable in C#

IEnumerable

Namespace: System.Collections

An IEnumerable is a list or a container which can hold some items. You can iterate through each element in the IEnumerable. You can not edit the items like adding, deleting, updating, etc. instead you just use a container to contain a list of items. It is the most basic type of list container.

All you get in an IEnumerable is an enumerator that helps in iterating over the elements. An IEnumerable does not hold even the count of the items in the list, instead, you have to iterate over the elements to get the count of items.

An IEnumerable supports filtering elements using where clause.

ICollection

Namespace: System.Collections

ICollection is another type of collection, which derives from IEnumerable and extends it’s functionality to add, remove, update element in the list. ICollection also holds the count of elements in it and we does not need to iterate over all elements to get total number of elements.

The count of total items can be retrieved in O(1) time.

ICollection supports enumerating over the elements, filtering elements, adding new elements, deleting existing elements, updating existing elements and getting the count of available items in the list.

IList

Namespace: System.Collections

IList extends ICollection. An IList can perform all operations combined from IEnumerable and ICollection, and some more operations like inserting or removing an element in the middle of a list.

You can use a foreach loop or a for loop to iterate over the elements.

IQueryable

Namespace: System.Linq

IQueryable extends ICollection. An IQueryable generates a LINQ to SQL expression that is executed over the database layer. Instead of the generating a Func<T, bool> like the ones above, IQueryable generates an expression tree and gives Expression<Func<T, bool>> that is executed over the database layer to get data set.

Thursday, April 15, 2021

Azure Service Bus

 

What is Azure Service Bus?

  • Load-balancing work across competing workers
  • Safely routing and transferring data and control across service and application boundaries
  • Coordinating transactional work that requires a high-degree of reliability

Overview

Data is transferred between different applications and services using messages. A message is a container decorated with metadata, and contains data. The data can be any kind of information, including structured data encoded with the common formats such as the following ones: JSON, XML, Apache Avro, Plain Text.

Some common messaging scenarios are:

  • Messaging. Transfer business data, such as sales or purchase orders, journals, or inventory movements.

  • Decouple applications. Improve reliability and scalability of applications and services. Producer and consumer don't have to be online or readily available at the same time. The load is leveled such that traffic spikes don't overtax a service.

  • Load Balancing. Allow for multiple competing consumers to read from a queue at the same time, each safely obtaining exclusive ownership to specific messages.

  • Topics and subscriptions. Enable 1:n relationships between publishers and subscribers, allowing subscribers to select particular messages from a published message stream.

  • Transactions. Allows you to do several operations, all in the scope of an atomic transaction. For example, the following operations can be done in the scope of a transaction.

    1. Obtain a message from one queue.
    2. Post results of processing to one or more different queues.
    3. Move the input message from the original queue.

    The results become visible to downstream consumers only upon success, including the successful settlement of input message, allowing for once-only processing semantics. This transaction model is a robust foundation for the compensating transactions pattern in the greater solution context.

  • Message sessions. Implement high-scale coordination of workflows and multiplexed transfers that require strict message ordering or message deferral.

If you're familiar with other message brokers like Apache ActiveMQ, Service Bus concepts are similar to what you know. As Service Bus is a platform-as-a-service (PaaS) offering, a key difference is that you don't need to worry about the following actions. Azure takes care of those chores for you.

  • Placing logs and managing disk space
  • Handling backups
  • Keeping the operating systems or the products patched
  • Worrying about hardware failures
  • Failing over to a reserve machine

Friday, January 15, 2021

Protocols :

protocol is a set of rules that governs the communications between computers on a network. In order for two computers to talk to each other, they must be speaking the same language

Types of Protocols

  • Transmission Control Protocol (TCP)
  • Internet Protocol (IP)
  • User Datagram Protocol (UDP)
  • Post office Protocol (POP)
  • Simple mail transport Protocol (SMTP)
  • File Transfer Protocol (FTP)
  • Hyper Text Transfer Protocol (HTTP)
  • Hyper Text Transfer Protocol Secure (HTTPS)

Saturday, January 9, 2021

Visual Studio, Framework and Core Versions

 

Product nameCode nameRelease dateVersion
number
Latest Update VersionLatest Update DateSupport EndsSupported
.NET Framework
(no add-on)
Supported
.NET Core
(no add-on)
Visual Studio 2019Dev162019-04-02[63]16.016.8.3[64]2020-11-10date to be determined[66]3.5 - 4.82.1, 2.2, 3.0, 3.1, 5.0[67]
Visual Studio 2017Dev15[68]2017-03-07[69]15.015.9.29[70]2020-11-10April 13, 2027[71]3.5 - 4.7.21.0-1.1, 2.0, 2.1
Visual Studio 2015Dev14[72]2015-07-20[73][74]14.0Update 3[75]2016-06-27October 14, 2025[76]2.0 - 4.6.11.0
Visual Studio 2013Dev12[72]2013-10-17[77][78]12.0Update 5[73]2015-07-20April 9, 2024[79]2.0 - 4.5.1N/A
Visual Studio 2012Dev11[72]2012-09-12[80][81][82]11.0Update 5[83]2015-08-24January 10, 2023[84]2.0 - 4.5N/A
Visual Studio 2010Dev10[85]2010-04-12[86][87]10.0Service Pack 1[88][89]2011-03-10July 14, 2020[90]2.0 - 4.0N/A
Visual Studio 2008Orcas[91]2007-11-19[92]9.0Service Pack 1[93]2008-08-11April 10, 2018[94]2.0, 3.0, 3.5N/A
Visual Studio 2005Whidbey[95]2005-11-07[96]8.0Service Pack 1[97]2006-12-15April 12, 2016[98]2.0N/A
Visual Studio .NET 2003Everett[99]2003-04-24[100]7.1Service Pack 1[101]2006-08-15October 14, 2013[102]1.1N/A
Visual Studio .NET (2002)Rainier[103]2002-02-13[104]7.0Service Pack 1[105]2005-03-08July 14, 2009[106]1.0N/A
Visual Studio 6.0Aspen[107]1998-09-02[108][109]6.0Service Pack 6[110]2004-03-29September 30, 2005[111][112]N/AN/A
Visual Studio 97Boston[113]1997-03-19[114][115][116]5.0Service Pack 31997-12-04June 30, 2003[117][118]N/AN/A