Wednesday, April 7, 2010

Naming Conventions in SQL Server

Restrict the remaining characters in your identifiers to alphabetic characters (A–Z, a–z, and Unicode Standard 3.2 letters), numeric digits (0–9), and the underscore character (_). The dollar sign ($) character, while allowed, is not advisable.

• SQL Server variable names that start with the at sign (@),
• temporary tables and procedures that start with the number sign (#)
• global temporary tables and procedures that begin with the double number sign (##).
• Many built-in T-SQL functions and system variables have names that begin with a double at sign (@@),such as @@ERROR and @@IDENTITY.

Friday, March 19, 2010

Simple LINQ Examples


Linq command


output


“shashi”


shashi


"YES!!!".Dump ("Foreign
key constraints"
);



Foreign key constraints


YES!!!


from n in new[]
{
"Tom", "Dick", "Harry" }

where n.Contains ("a")

select n



5IEnumerable<String>
(1 item)


Harry


from word in "The
quick brown fox jumps over the lazy dog"
.Split()

orderby word.Length

select word



5IOrderedEnumerable<String>
(9 items)


The


fox


the


dog


over


lazy


quick


brown


jumps


var words =

    
from
word
in "The
quick brown fox jumps over the lazy dog"
.Split()

    
orderby
word.ToUpper()

    
select
word;

    

var duplicates =

    
from
word
in words

    
group
word.ToUpper()
by word.ToUpper() into g

    
where
g.Count() >
1

    
select new {
g.Key, Count = g.Count() };



5IOrderedEnumerable<String>
(9 items)


brown


dog


fox


jumps


lazy


over


quick


The


the


5IEnumerable<>
(1 item)


Key


Count


THE


2




123.Dump();

Regex.Match (
"my favorite color is...", "colou?r").Dump();

formatting:

TimeZoneInfo.Local.Dump (
"Bet you never knew this type
existed!"
);







new[] { 11, 5, 17, 7, 13
}    .Dump (
"Prime
numbers"
)

.Where (n => n >
10)        .Dump
(
"Prime numbers > 10")

.OrderBy (n =>
n)            .Dump
(
"Prime numbers > 10 sorted")

.Select (n => n *
10)
        .Dump (
"Prime
numbers > 10 sorted, times 10!"
);

123


5Match


color


Groups



5GroupCollection
(1 item)



qMatch


color


Success


True


Captures



5CaptureCollection
(1 item)



qMatch


color


Index


12


Length


5


Value


color


▪ Bet you never knew
this type existed!



5TimeZoneInfo


(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi


Id


India Standard Time


DisplayName


(GMT+05:30) Chennai, Kolkata, Mumbai,
New Delhi


StandardName


India Standard Time


DaylightName


India Daylight Time


BaseUtcOffset


05:30:00


SupportsDaylightSavingTime


False

 


▪ Prime numbers



5Int32[] (5
items)


11


5


17


7


13

 


▪ Prime numbers >
10



5IEnumerable<Int32>
(3 items)


11


17


13

 


▪ Prime numbers >
10 sorted



5IOrderedEnumerable<Int32>
(3 items)


11


13


17

 


▪ Prime numbers >
10 sorted, times 10!



5IEnumerable<Int32>
(3 items)


110


130


170


(new[] {"Tom", "Dick", "Harry"}
).Where (n => n.Length >=
4)



5IEnumerable<String>
(2 items)


Dick


Harry


 


 


Microsoft SharePoint Server 2010 (Beta)

http://technet.microsoft.com/en-us/sharepoint/ee263917.aspx

What's New in SharePoint Server 2010?

What's New: Business Connectivity Services (BCS)

What's New: Enterprise Content Management (ECM)

What's New: SharePoint Enterprise Search

What's New: PerformancePoint Services

What's New: Excel Services

What's New: User Profiles and Social Data

Word Automation Services Overview

http://msdn.microsoft.com/en-us/library/ee557323(office.14).aspx
Detect if string is numeric
// Detect if a string is numeric

public static bool IsNumeric(string text)
{
return Regex.IsMatch(text,"^\\d+$");
}
-----------------------
Protect string content by marshalling
// Protect string content by marshalling

IntPtr bstr = Marshal.SecureStringToBSTR(password);

try
{
// ...
// use the bstr
// ...
}
finally
{
Marshal.ZeroFreeBSTR(bstr);
}

Locate string on webpage

private bool SearchPage(string URL, string StrToLocate)
{
StreamReader SR;
WebResponse Resp ;
WebRequest MyWebRequest;
string PageStr;

MyWebRequest = WebRequest.Create(URL) ;
MyWebRequest.Timeout = 10000 ;
try
{
Resp = MyWebRequest.GetResponse() ;
SR = new StreamReader(Resp.GetResponseStream()) ;
PageStr = SR.ReadToEnd() ;
SR.Close() ;

PageStr = PageStr.ToUpper();
if ( PageStr.IndexOf(StrToLocate.ToUpper(), 0, PageStr.Length) != -1 )
return true;
else
return false;
}

catch ( WebException wex )
{
if (wex.Status == WebExceptionStatus.Timeout)
Response.Write("The request has timed out!") ;

else
Response.Write("There was some exception: " + wex.Message) ;

return false;
}

}