Random scripts
SQL transaction try catch template
BEGIN TRAN
— sql goes here
COMMIT
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage
ROLLBACK
END CATCH
Very nice blog around WCF security
Search object name within SQL database
WHERE id IN
( SELECT id FROM syscolumns WHERE name = ‘keyword’ )
Close remote desktop session on remote server
>rwinsta /server:server_ip_here id_here
Some Syntax
[MethodImpl(MethodImplOptions.Synchronized)]
public void HelloWorld(){}
lambda
Console.CancelKeyPress += (sender, e) => { Console.WriteLine(“CTRL+C detected!\n”); e.Cancel = true;};
anonymous type
void Do()
{
Foo(new {Name=”wall-e”, Age=999}, new {Name=default(string), Age=default(int)});
}
T Foo
{
return (T) obj;
}
anonymous type infer property name
string a = “this is a”;
string b= “this is b”;
var obj = {a, b};
Console.WriteLine(obj.a);
Console.WriteLine(obj.b);
without calling any finally blocks or finalizers
Environment.FailFast()
deriving class must contain parameterless constructor
public interface MyClass
using different version of class
extern alias oldVer;
extern alias newVer;
using System;
csc /r:oldVer=Somepath\ClassLibrary.dll /r:newVer=AnotherPath\ClassLibrary.dll program.cs
Environment.UserInteractive is false when no UI for the app.
Empty sln file of 2008 content
# Visual Studio 2008
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
WCF where are all the namespaces defined in WSDL
wsdl:definitions [ServiceBehavior] wsdl:portType [ServiceContract] wsdl:part> [MessageContract] xs:schema [DataContract] [MessageContract] [MessageBodyMember] binding bindingNamespace on endpoint