Temp table in SQL Server(#temp,##temp,@table)

Temporary tables are useful when we want a manipulated data in tabular form at run time in query processing. A temporary table is visible to the session in which they were created and are automatically dropped when that session logs off.

Type of temp table

1) Local temp table: Syntax (create table #t).

If a temp table exist in a stored procedure it is automatically dropped when SP ends, i.e. temp table exist in current scope and current connection.

2) Global temp table: Syntax (create table ##t).

Global temp table can be accessed in any session in current connection and can be dropped in any session.

3) Temp variable: Syntax (create table @t)

A temp variable has all features of temp table but

It can’t be dropped manually,they are dropped automatically.

We can use a temp variable in user defined function but can’t do with temp table.

IEnumerable and IQueryable Interface in C #

IEnumerable<T> Interface in C #

IEnumerable interface is a simple iteration over a collection of a specified type.It has Method GetEnumerator() that iterates through the collection.
Use: Mainly used to work with in memory data i.e List,Array
Example: IEnumerable<Product> products = db.employee.Take(3);

IQueryable Interface in C #

It is basically used to evaluate queries against a specific data source.
Use: Used to query database.e.g. iin LINQ
Example: IQueryable<Product> products = db.employee.Take(3);

Difference:

In IEnumerable All employees will be loaded After Loading all data program will filter
Query run on database- Select * from Employees
In IQueryable Data will be filterd on Database Program will get only top 3 recoreds
Query run on database- Select TOP 3 * from Employees

Extension Methods in C#

With help of extension method you can add a new method to an existing type without recompile and modifying existing type.

e.g.

string s = “hello”; string i = s.UpperCasefirstLater();

Result : Hello

Here UpperCasefirstLater is a extension method. see below code
public static class MyExtensions
{
public static string UpperCasefirstLater(this String str)
{
if (str.Length > 0)
{
char[] array = str.ToCharArray();
array[0] = char.ToUpper(array[0]);
return new string(array);
}
}
}