How to pronounce symbols on keyboard?


copied from here

~ “tilde” or “tweedle” or “squiggly line”. Also used as a “swung dash” and in mathematics with other signs to mean “approximately” and in logic sometimes used to mean “not”. See Tilde on wiki

``` “grave accent” or “stress mark”. See… .

! “exclamation point” or “exclamation mark’. Used to end an emphatic sentence. Also often used in computer languages to mean “not” and in mathematics to indicate “factorial’. See Exclamation on wiki.

@ “at sign” or “commercial at sign”. See it on wiki.

# “number sign” or “pound sign’ or “octothorpe” or “hash mark”

$ “dollar sign”, for example $29.00 would be read as “twenty-nine dollars’

Read More »

Differences between StoredProcedure and UDF


The differences between Stored Procedure (SP) and User Defined Functions (UDF) in MSSQL

Ability SP UDF
Return Values Can return zero, single or multiple values Mandatory to return one and only one value
Can use transaction Yes No
Can have input/output parameters Both Input parameters only
Interop Can call functions from SP Cannot call SP from function
Can be used in SELECT WHERE HAVING statement No Yes
Exception Handling Yes, can Try-Catch NO

Written with StackEdit.

Read More »

Extract SQL Query From Linq Expression


##How to Extract sql query from LINQ expressions?

###GetCommand You can use the DataContext.GetCommand method to get the generated SQL:

var query = dataContext.Persons.Where(p => p.Name == "Alice");
string generatedSql = dataContext.GetCommand(query).CommandText;

###Display in VisualStudio Output Window Redirect/set the DataContext’s log to Console.Out. Then we can see the SQL statements in the VisualStudio’s output window when the query gets executed.

dataContext.Log = Console.Out;
var query = dataContext.Persons.Where(p => p.Name == "Alice");
var persons = query.ToList();

Written with StackEdit.

Read More »

Insert Value for Identity Column in MSSQL



Sometimes we want to copy a table that contains an identity column from another one exactly with the id column’s values kept, e.g. Migration, Recovering from a backup table. In this case we need to turn on the IDENTITY_INSERT, which enables the ability to insert specific values into the target table. And after inserted we should turn it off to bring the behaviour back to normal.

The following commands work on MSSQLServer.

# to turn on
# to turn off

Written with StackEdit.

Read More »

ElementName As Source Of Content Menu Command Binding


ElementName As Source Of Content Menu Command Binding

We can’t bind using ElementName for a context menu command binding as popups are not on the visual tree, thus not able to find the element by its name. But we can workaround it using a couple of tricks though…

  1. Use RoutedUICommands with a command binding on the UserControl, then no binding is needed.
  2. Use the placement target binding on the context menu’s DataContext. This allows you to at least get the data context of the element the context menu appears on to the context menu.

    DataContext=”{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}”.

  3. Use [ElementSpy][1] to link to the window using a static resource so we can then use a defacto ElementName bindings.

Copied and modified from here

Written with StackEdit.

Read More »