<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss"><id>tag:blogger.com,1999:blog-4971377397859266634</id><updated>2009-11-04T12:49:13.539-05:00</updated><title type="text">Keeping up with Microsoft</title><subtitle type="html">Blogs on code snippets and tools that every .NET developer would need to have on fingerTips</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default?start-index=26&amp;max-results=25" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>67</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="self" href="http://feeds.feedburner.com/Aspnet" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-2169214838465405114</id><published>2009-03-06T17:32:00.001-05:00</published><updated>2009-03-06T17:32:41.694-05:00</updated><title type="text">Dispose and Finalize methods and .NET Memory optimizations</title><content type="html">&lt;p&gt;I have jotted down a few points on implementing the IDisposable and Finalize patterns in .NET.&lt;/p&gt;  &lt;p&gt;Please find it here : &lt;a target="_blank" href="http://geekswithblogs.net/rgupta/archive/2009/03/06/dispose-and-finalize-methods.aspx"&gt;Dispose and Finalize methods&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I also jotted down some .net Memory Optimization tips: Please find them here : &lt;a target="_blank" href="http://geekswithblogs.net/rgupta/archive/2009/03/06/some-tips-on-.net-memory-usage.aspx"&gt;Some Tips on .NET Memory optimizations&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-2169214838465405114?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/2169214838465405114/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=2169214838465405114" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/2169214838465405114" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/2169214838465405114" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2009/03/dispose-and-finalize-methods-and-net.html" title="Dispose and Finalize methods and .NET Memory optimizations" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-4264128135865972160</id><published>2009-03-03T19:57:00.001-05:00</published><updated>2009-03-03T19:57:00.509-05:00</updated><title type="text">Creating dynamically generated logfiles with log4net</title><content type="html">&lt;p&gt;If you need to generate logfile names dynmically when using log4net then we can do this using the log4net Properties.&lt;/p&gt;  &lt;p&gt;To learn more on this please visit : &lt;a target="_blank" href="http://geekswithblogs.net/rgupta/archive/2009/03/03/dynamic-log-filenames-with-log4net.aspx"&gt;creating dynamic logfile names with log4net&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-4264128135865972160?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/4264128135865972160/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=4264128135865972160" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4264128135865972160" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4264128135865972160" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2009/03/creating-dynamically-generated-logfiles.html" title="Creating dynamically generated logfiles with log4net" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-1205303643478543223</id><published>2009-03-03T18:55:00.001-05:00</published><updated>2009-03-03T18:55:55.929-05:00</updated><title type="text">Tips on using log4net RollingFileAppender</title><content type="html">&lt;p&gt;I have compiled a list of useful properties that you can set on the RollingFileAppender in the log4net XML config file which can determine the order in which log file backups will be generated, whether they will rollover based on dates or size or both.&lt;/p&gt;  &lt;p&gt;For more information please check this link out : &lt;a target="_blank" href="http://geekswithblogs.net/rgupta/archive/2009/03/03/tips-on-using-log4net-rollingfileappender.aspx"&gt;Tips on using log4net RollingFileAppender&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-1205303643478543223?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/1205303643478543223/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=1205303643478543223" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/1205303643478543223" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/1205303643478543223" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2009/03/tips-on-using-log4net.html" title="Tips on using log4net RollingFileAppender" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-1827192027572300480</id><published>2009-01-28T20:06:00.001-05:00</published><updated>2009-01-28T20:12:33.130-05:00</updated><title type="text">ConfigSectionHandler for Hierarchical configs</title><content type="html">Here is a quick way to create a ConfigSection Handler for reading Hierarchical configs.  For e.g. suppose you need to read a config file which has the following structure:  &lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;&lt;mainconfig&gt;&lt;company&gt;MySpace&lt;/company&gt; &lt;br /&gt;	&lt;subconfig&gt;&lt;br /&gt;		&lt;id&gt;23&lt;/id&gt;&lt;br /&gt;		 &lt;firstname&gt;Rohit&lt;/firstname&gt; &lt;br /&gt;		&lt;lastname&gt;Gupta&lt;/lastname&gt;&lt;br /&gt;	 &lt;/subconfig&gt;&lt;br /&gt;&lt;/mainconfig&gt;&lt;br /&gt;&lt;/pre&gt;For this you would create the 2 classes, one for the Parent Config and another for the chold config like this: &lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;   [XmlRoot("MainConfig")]&lt;br /&gt;    public class MainConfig&lt;br /&gt;    {&lt;br /&gt;        private static readonly MainConfig instance = &lt;br /&gt;	(MainConfig)ConfigurationManager.GetSection("MainConfig");&lt;br /&gt;        public static MainConfig GetInstance()&lt;br /&gt;        {&lt;br /&gt;            if (instance == null)&lt;br /&gt;                throw new ConfigurationErrorsException(&lt;br /&gt;                    "Unable to locate or deserialize the 'MainConfig' section.");&lt;br /&gt;&lt;br /&gt;            return instance;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string Company { get; set; }&lt;br /&gt;&lt;br /&gt;        public SubConfig FriendsConfig { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [XmlRoot("SubConfig")]&lt;br /&gt;    public class SubConfig&lt;br /&gt;    {&lt;br /&gt;        public int ID { get; set; }&lt;br /&gt;        public string Name { get; set; }&lt;br /&gt;        public string LastName { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then you would create a configsectionHandler class which reads the config from the .config file: &lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;&lt;br /&gt; public class MainConfigSectionHandler : IConfigurationSectionHandler&lt;br /&gt;    {&lt;br /&gt;        #region IConfigurationSectionHandler Members&lt;br /&gt;&lt;br /&gt;        public object Create(object parent, object configContext, System.Xml.XmlNode section)&lt;br /&gt;        {&lt;br /&gt;            MainConfig typedConfig = GetConfig&lt;MainConfig&gt;(section);&lt;br /&gt;&lt;br /&gt;            if (typedConfig != null)&lt;br /&gt;            {&lt;br /&gt;                #region Get Sub Configs&lt;br /&gt;                foreach (XmlNode node in section.ChildNodes)&lt;br /&gt;                {&lt;br /&gt;                    switch (node.Name)&lt;br /&gt;                    {&lt;br /&gt;                        case "SubConfig":&lt;br /&gt;                            SubConfig friendsConfig = GetConfig&lt;SubConfig&gt;(node);&lt;br /&gt;                            typedConfig.FriendsConfig = friendsConfig;&lt;br /&gt;                            break;&lt;br /&gt;                        default:&lt;br /&gt;                            break;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;                #endregion&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            return typedConfig;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public T GetConfig&lt;T&gt;(System.Xml.XmlNode section) where T : class&lt;br /&gt;        {&lt;br /&gt;            T sourcedObject = default(T);&lt;br /&gt;            Type t = typeof(T);&lt;br /&gt;            XmlSerializer ser = new XmlSerializer(typeof(T));&lt;br /&gt;            sourcedObject = ser.Deserialize(new XmlNodeReader(section)) as T;&lt;br /&gt;            return sourcedObject;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After this you would add a entry in the app.config for this configsection Handler as the following: &lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;	&lt;configSections&gt;&lt;br /&gt;		&lt;section name="MainConfig" type="App.MainConfigSectionHandler,App" /&gt;&lt;br /&gt;	&lt;/configSections&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Finally to read this config, you would write the following: &lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;MainConfig config = MainConfig.GetInstance(); Console.WriteLine(config.Company); &lt;br /&gt;Console.WriteLine(config.FriendsConfig.ID); &lt;br /&gt;Console.WriteLine(config.FriendsConfig.LastName); &lt;br /&gt;Console.WriteLine(config.FriendsConfig.Name);&lt;br /&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-1827192027572300480?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/1827192027572300480/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=1827192027572300480" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/1827192027572300480" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/1827192027572300480" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2009/01/configsectionhandler-for-hierarchical.html" title="ConfigSectionHandler for Hierarchical configs" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-4350966255596572413</id><published>2009-01-07T21:45:00.004-05:00</published><updated>2009-01-11T04:12:28.993-05:00</updated><title type="text">Lucene: Multifield searches</title><content type="html">&lt;p&gt;We can run multifield searches in Lucene using either the BooleanQuery API or using the MultiFieldQueryParser for parsing the query text. For e.g. If a index has 2 fields FirstName and LastName and if you need to search for "John" in the FirstName field and "Travis" in the LastName field one can use a Boolean Query as such: &lt;/p&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;BooleanQuery bq = new BooleanQuery();&lt;br /&gt;Query qf = new TermQuery(new Lucene.Net.Index.Term("FirstName", "John"));&lt;br /&gt;Query ql = new TermQuery(new Lucene.Net.Index.Term("LastName", "Travis"));&lt;br /&gt;bq.Add(qf, BooleanClause.Occur.MUST);&lt;br /&gt;bq.Add(ql, BooleanClause.Occur.MUST);&lt;br /&gt;IndexSearcher srchr = new IndexSearcher(@"C:\indexDir");&lt;br /&gt;srchr.Search(bq);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt; Now if we need to search a single term across either of the FirstName and LastName fields then we can use the MultiFieldQueryParser as follows:&lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;Query query = MultiFieldQueryParser.parse("commonName",&lt;br /&gt;new String[] { "FirstName", "LastName" },&lt;br /&gt;new SimpleAnalyzer());&lt;br /&gt;srchr.Search(query);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt; Now if you need to search the term that must exist in both the fields then we use the following:&lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt; Query query = MultiFieldQueryParser.Parse("commonName",&lt;br /&gt;new String[] { "FirstName", "LastName" },&lt;br /&gt;new BooleanClause.Occur[] { BooleanClause.Occur.MUST,BooleanClause.Occur.MUST}&lt;br /&gt;, new SimpleAnalyzer());&lt;br /&gt;srchr.Search(query);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt; Finally if you don’t want a term to occur in one of the Fields (say FirstName) then use:&lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt; Query query = MultiFieldQueryParser.Parse("commonName",&lt;br /&gt;new String[] { "FirstName", "LastName" },&lt;br /&gt;new BooleanClause.Occur[] { BooleanClause.Occur.MUST_NOT,BooleanClause.Occur.MUST},&lt;br /&gt;new SimpleAnalyzer());&lt;br /&gt;srchr.Search(query);  &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt; &lt;div&gt;so if you need to search a single term across multiple fields then use MultiFieldQueryParser, if you need to search different terms in different fields then use the BooleanQuery as shown first&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-4350966255596572413?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/4350966255596572413/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=4350966255596572413" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4350966255596572413" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4350966255596572413" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2009/01/lucene-multifield-searches.html" title="Lucene: Multifield searches" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-5511951365340036793</id><published>2008-12-01T12:59:00.001-05:00</published><updated>2008-12-01T13:04:50.963-05:00</updated><title type="text">Dynamically creating types using reflection and setting properties using Reflection.Emit.</title><content type="html">I came across a requirement where we needed to create types dynamically based on XML Configuration files, so that in the furture new types are required we dont need to update the application again by creating a new class.  &lt;br/&gt; The additional requirement was to populate the property names of the class based on the Cml configuration and its values using the Querystring values from the HttpWebRequest. &lt;br/&gt; I earlier thought about using &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/exczf7b9.aspx"&gt;Dynamic methods&lt;/a&gt; from .NET Framework 2.0, but that did not fit my purpose since I didn't need to execute methods from the dynamic type that was created. &lt;br/&gt;&lt;br/&gt; So here is the code: &lt;br/&gt; I created three helper methods &lt;br/&gt; 1. Generates the AssemblyBuilder and Module Builder objects  &lt;br/&gt; 2. Generates the TypeBuilder object.. which will be used for generating an instance of the dynamic type using Activator.CreateInstance  &lt;br/&gt;3. Create properties using Relection.Emit &lt;br/&gt; &lt;div&gt;&lt;div style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%;"&gt; &lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;class&lt;/span&gt; DynamicType&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   3:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;static&lt;/span&gt; AssemblyBuilder asmBuilder = &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;static&lt;/span&gt; ModuleBuilder modBuilder = &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;void&lt;/span&gt; GenerateAssemblyAndModule()&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   7:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   8:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (asmBuilder == &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   9:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  10:&lt;/span&gt;             AssemblyName assemblyName = &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; AssemblyName();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  11:&lt;/span&gt;             assemblyName.Name = &lt;span style="color: #006080;"&gt;"DWBeacons"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  12:&lt;/span&gt;             AppDomain thisDomain = Thread.GetDomain();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  13:&lt;/span&gt;             asmBuilder = thisDomain.DefineDynamicAssembly(&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  14:&lt;/span&gt;                          assemblyName, AssemblyBuilderAccess.Run);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  15:&lt;/span&gt;             modBuilder = asmBuilder.DefineDynamicModule(&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  16:&lt;/span&gt;                          asmBuilder.GetName().Name, &lt;span style="color: #0000ff;"&gt;false&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  17:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  18:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  19:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  20:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;static&lt;/span&gt; TypeBuilder CreateType(ModuleBuilder modBuilder, &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; typeName)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  21:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  22:&lt;/span&gt;         TypeBuilder typeBuilder = modBuilder.DefineType(typeName,&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  23:&lt;/span&gt;                     TypeAttributes.Public |&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  24:&lt;/span&gt;                     TypeAttributes.Class |&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  25:&lt;/span&gt;                     TypeAttributes.AutoClass |&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  26:&lt;/span&gt;                     TypeAttributes.AnsiClass |&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  27:&lt;/span&gt;                     TypeAttributes.BeforeFieldInit |&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  28:&lt;/span&gt;                     TypeAttributes.AutoLayout,&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  29:&lt;/span&gt;                     &lt;span style="color: #0000ff;"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff;"&gt;object&lt;/span&gt;));&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  30:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; typeBuilder;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  31:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  32:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  33:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  34:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;void&lt;/span&gt; CreateProperty(TypeBuilder t, &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; name, Type typ)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  35:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  36:&lt;/span&gt;         &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; field = &lt;span style="color: #006080;"&gt;"_"&lt;/span&gt; + name.ToLower();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  37:&lt;/span&gt;         FieldBuilder fieldBldr = t.DefineField(field, typ, FieldAttributes.Private);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  38:&lt;/span&gt;         PropertyBuilder propBldr = t.DefineProperty(name, PropertyAttributes.HasDefault, typ, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  39:&lt;/span&gt;         MethodAttributes getSetAttr = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  40:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  41:&lt;/span&gt;         MethodBuilder getPropBldr = t.DefineMethod(&lt;span style="color: #006080;"&gt;"get_"&lt;/span&gt; + name, getSetAttr, typ, Type.EmptyTypes);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  42:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  43:&lt;/span&gt;         ILGenerator getIL = getPropBldr.GetILGenerator();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  44:&lt;/span&gt;         getIL.Emit(OpCodes.Ldarg_0);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  45:&lt;/span&gt;         getIL.Emit(OpCodes.Ldfld, fieldBldr);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  46:&lt;/span&gt;         getIL.Emit(OpCodes.Ret);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  47:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  48:&lt;/span&gt;         MethodBuilder setPropBldr = t.DefineMethod(&lt;span style="color: #006080;"&gt;"set_"&lt;/span&gt; + name, getSetAttr, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; Type[] { typ });&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  49:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  50:&lt;/span&gt;         ILGenerator setIL = setPropBldr.GetILGenerator();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  51:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  52:&lt;/span&gt;         setIL.Emit(OpCodes.Ldarg_0);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  53:&lt;/span&gt;         setIL.Emit(OpCodes.Ldarg_1);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  54:&lt;/span&gt;         setIL.Emit(OpCodes.Stfld, fieldBldr);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  55:&lt;/span&gt;         setIL.Emit(OpCodes.Ret);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  56:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  57:&lt;/span&gt;         propBldr.SetGetMethod(getPropBldr);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  58:&lt;/span&gt;         propBldr.SetSetMethod(setPropBldr);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  59:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  60:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  61:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  62:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Then to use these helper methods from the Main program I used the following:&lt;br /&gt;&lt;div&gt;&lt;div style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%;"&gt;&lt;br /&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (DynamicType.asmBuilder == &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   2:&lt;/span&gt;     DynamicType.GenerateAssemblyAndModule();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   3:&lt;/span&gt; finalType = DynamicType.modBuilder.GetType(&lt;span style="color: #006080;"&gt;"Beacon11"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   4:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   5:&lt;/span&gt; TypeBuilder tb = DynamicType.CreateType(DynamicType.modBuilder, typeName);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   6:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;foreach&lt;/span&gt; (XElement e &lt;span style="color: #0000ff;"&gt;in&lt;/span&gt; beaconNode.Descendants())&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   8:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;   9:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; pname = e.Attribute(&lt;span style="color: #006080;"&gt;"qs"&lt;/span&gt;).Value;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; ptype = e.Attribute(&lt;span style="color: #006080;"&gt;"type"&lt;/span&gt;).Value;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  11:&lt;/span&gt;     DynamicType.CreateProperty(tb, pname, Type.GetType(ptype));&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  13:&lt;/span&gt; finalType = tb.CreateType();&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  14:&lt;/span&gt; &amp;nbsp;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  15:&lt;/span&gt; Object obj = Activator.CreateInstance(finalType);&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  16:&lt;/span&gt; &lt;span style="color: #008000;"&gt;// this sets the properties of the just instantiated class&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  17:&lt;/span&gt; finalType.InvokeMember(&lt;span style="color: #006080;"&gt;"bv"&lt;/span&gt;, BindingFlags.SetProperty, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;, data, &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;object&lt;/span&gt;[] { 1.0 });&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  18:&lt;/span&gt; finalType.InvokeMember(&lt;span style="color: #006080;"&gt;"tp"&lt;/span&gt;, BindingFlags.SetProperty, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;, data, &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;object&lt;/span&gt;[] { 2.0 });&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  19:&lt;/span&gt; &lt;span style="color: #008000;"&gt;//this sets the properties of the type by using values from the querystring&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  20:&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;foreach&lt;/span&gt; (XElement e &lt;span style="color: #0000ff;"&gt;in&lt;/span&gt; beaconNode.Descendants())&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  21:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  22:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;string&lt;/span&gt; pname = e.Attribute(&lt;span style="color: #006080;"&gt;"qs"&lt;/span&gt;).Value;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  23:&lt;/span&gt;     &lt;span style="color: #0000ff;"&gt;object&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;value&lt;/span&gt; = context.Request.QueryString[pname];&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  24:&lt;/span&gt;     finalType.InvokeMember(pname, BindingFlags.SetProperty, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;, data, &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;object&lt;/span&gt;[] { &lt;span style="color: #0000ff;"&gt;value&lt;/span&gt; });&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;&lt;span style="color: #606060;"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For more information visit : &lt;a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.propertybuilder.aspx" target="_blank"&gt;msdn - PropertyBuilder&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-5511951365340036793?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/5511951365340036793/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=5511951365340036793" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/5511951365340036793" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/5511951365340036793" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/12/dynamically-creating-types-using.html" title="Dynamically creating types using reflection and setting properties using Reflection.Emit." /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-3924405795540805746</id><published>2008-11-18T13:32:00.001-05:00</published><updated>2008-11-18T13:34:57.372-05:00</updated><title type="text">Schedule a task using C# code</title><content type="html">I needed to schedule a task to run every day at 9:00 p.m. in the night. I had an addition al requirement that the task be scheduled only if the FileSystemwatcher alerts us of new files being available for processing.&lt;br/&gt;&lt;br/&gt;  Thus the files could be recieved anytime during the day, but despite that the task should be schduled to run exactly at 9:00 p.m. in the night.&lt;br/&gt;&lt;br/&gt;  So I used the following code to schedule a task(using System.Threading.Timer and TimeSpan classes) &lt;br/&gt;&lt;br/&gt;  &lt;div&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;DateTime d = DateTime.Now;&lt;br/&gt;&lt;br /&gt;timer = &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; Timer(&lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; TimerCallback(Update), &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;, &lt;br /&gt;TimeSpan.FromMinutes(21 * 60 - (d.Hour * 60 + d.Minute)), &lt;br /&gt;TimeSpan.FromMilliseconds(-1));&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Note I used TimeSpan.FromMillisecnods(-1) to disable periodic signalling  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-3924405795540805746?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/3924405795540805746/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=3924405795540805746" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3924405795540805746" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3924405795540805746" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/11/schedule-task-using-c-code.html" title="Schedule a task using C# code" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-8483877860625290346</id><published>2008-11-13T14:40:00.001-05:00</published><updated>2008-11-13T14:40:13.760-05:00</updated><title type="text">Compare 2 SQL queries for equality</title><content type="html">&lt;div&gt;&lt;pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt;  border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;"&gt;DECLARE @check1 bigint&lt;br /&gt;DECLARE @check2 bigint&lt;br /&gt;&lt;br /&gt;Select @check1 = CHECKSUM_AGG(CHECKSUM(*))&lt;br /&gt;FROM&lt;br /&gt;(&lt;br /&gt;    SELECT *&lt;br /&gt;    FROM dbo.Orders (nolock)&lt;br /&gt;)&lt;br /&gt;AS Source&lt;br /&gt;&lt;br /&gt;Select @check2 = CHECKSUM_AGG(CHECKSUM(*))&lt;br /&gt;FROM&lt;br /&gt;(&lt;br /&gt;    SELECT *&lt;br /&gt;    FROM dbo.Orders (nolock)&lt;br /&gt;    WHERE IsSuccessful = 1&lt;br /&gt;)&lt;br /&gt;As Comparison&lt;br /&gt;&lt;br /&gt;IF @check1 = @check2&lt;br /&gt;    PRINT &lt;span style="color: #006080;"&gt;'Queries are Equal'&lt;/span&gt;&lt;br /&gt;ELSE&lt;br /&gt;    PRINT &lt;span style="color: #006080;"&gt;'Queries are NOT Equal'&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;If order of rows is different it will not effect the result &lt;br /&gt;It does not do execution plan comparisons, simply checks if the rows returned by the two queries are the same or not&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.troyd.net/How+To+Compare++Test+The+Equality+Of+Two+Queries+In+SQL+Server+With+SQL.aspx" target="_blank"&gt;More info&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-8483877860625290346?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/8483877860625290346/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=8483877860625290346" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/8483877860625290346" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/8483877860625290346" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/11/compare-2-sql-queries-for-equality.html" title="Compare 2 SQL queries for equality" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-677665481818187195</id><published>2008-11-12T16:56:00.001-05:00</published><updated>2008-11-12T16:58:45.589-05:00</updated><title type="text">Converting SQL2005 DBTimeStamp to Long for Comparison (Convert from Hex to long and decimal to Hex)</title><content type="html">If you need to Convert SQL 2005 DB TimeStamp values to Long then follow these steps: &lt;br/&gt; 1. Retrieve the DB TimeStamp value in a Byte Array (8 bytes long). &lt;br/&gt; 2. Convert the byte array into a Hexadecimal string &lt;br/&gt; 3. Convert the hexadecimal string to a long &lt;br/&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; BytesToLong(&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] bytes)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; ts = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt; b &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; bytes)&lt;br /&gt;        ts += b.ToString(&lt;span style="color: #006080"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;).PadLeft(2,Convert.ToChar(&lt;span style="color: #006080"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Convert.ToInt64(ts, 16);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;There is another method to convert the DBTimeStamp to Long, but I dont prefer this method since it can return negative values. The method is:&lt;br/&gt;&lt;br /&gt;1. Retrieve the DB TimeStamp value in a Byte Array (8 bytes long).&lt;br /&gt;2. Use BitConverter class to convert the byte array into long &lt;br /&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;long result = BitConverter.ToInt64(dbTimestamp, 0); &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Inorder to remedy this use the following to generate the same long value as in step 1:&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; FromDbTimestamp(&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] dbTimestamp)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; result = 0;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (dbTimestamp != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;        Array.Reverse(dbTimestamp);&lt;br /&gt;        result = BitConverter.ToInt64(dbTimestamp, 0);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;Finally to convert a long into the correct DBTimeStamp use this: &lt;br /&gt;&lt;div&gt;&lt;br /&gt;  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] ToDbTimestamp(&lt;span style="color: #0000ff"&gt;long&lt;/span&gt; timestamp)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] result = BitConverter.GetBytes(timestamp);&lt;br /&gt;    Array.Reverse(result);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-677665481818187195?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/677665481818187195/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=677665481818187195" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/677665481818187195" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/677665481818187195" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/11/converting-sql2005-dbtimestamp-to-long.html" title="Converting SQL2005 DBTimeStamp to Long for Comparison (Convert from Hex to long and decimal to Hex)" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-5250687481671371701</id><published>2008-10-13T13:23:00.001-04:00</published><updated>2008-10-13T18:12:08.292-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">Passing state to threads via anonymous calls</title><content type="html">&lt;p&gt;We already know that we can pass state into to Threads in 2 ways:&lt;/p&gt;  &lt;p&gt;1. using ParameterizedThreadStart delegate&lt;/p&gt; 2.using global variables(reference or value types) accessible to the main thread as well the instantiated thread. This is also the  way to share data amonst multiple threads. Infact the most common way to share data between threads is using static variables where application wide scope is desired. &lt;p&gt;3.using Thread.QueueUserWorkItem ... This differs from Parameterized ThreadStart delegate since it uses threads from a preconfigured ThreadPool instead of manually creating threads &lt;/p&gt;  There is another cool method to pass information to threads is via anonymous methods. For e.g.   &lt;div&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; mainMessage = &lt;span style="color: #006080"&gt;&amp;quot;Hello from Main !!!&amp;quot;&lt;/span&gt;;&lt;br /&gt;    Thread t = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Thread(&lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;() { Print(mainMessage);});&lt;br /&gt;    t.Start();&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Print(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; message)&lt;br /&gt;{&lt;br /&gt;    Console.Writeline(message);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;Advantage of using this technique is that, it provides strongly typed access to the parameters passed to the thread. The Target Method can accept &lt;strong&gt;&lt;u&gt;any&lt;/u&gt;&lt;/strong&gt; number of arguments, and no casting is required (unlike Parameterized Start where the passed state is an “object”) . The flip side, though, is that you must keep outer-variable semantics in mind &lt;br /&gt;&lt;br /&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-5250687481671371701?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/5250687481671371701/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=5250687481671371701" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/5250687481671371701" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/5250687481671371701" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/10/passing-state-to-threads-via-anonymous.html" title="Passing state to threads via anonymous calls" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-4916472706414653446</id><published>2008-09-26T20:57:00.004-04:00</published><updated>2008-10-13T18:12:08.292-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">Method Hiding... Polymorphism in C#</title><content type="html">&lt;h4&gt;In the following code:&lt;/h4&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; IBand&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ID {get;set;}&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name {get;set;}&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetStatus();&lt;br /&gt; }&lt;br /&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Band : IBand&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ID { get; set; }&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Band()&lt;br /&gt;     {&lt;br /&gt;         GetStatus();&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetStatus()&lt;br /&gt;     {&lt;br /&gt;         ID = 555;&lt;br /&gt;         Name = &lt;span style="color: #006080"&gt;&amp;quot;Ring&amp;quot;&lt;/span&gt;;&lt;br /&gt;         Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Base Class Called&amp;quot;&lt;/span&gt;);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; ABand : Band, IBand&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Update { get; set; }&lt;br /&gt;&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ABand() : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;() {}&lt;br /&gt;&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetStatus()&lt;br /&gt;     {&lt;br /&gt;         ID = 655;&lt;br /&gt;         Name = &lt;span style="color: #006080"&gt;&amp;quot;TEsst&amp;quot;&lt;/span&gt;;&lt;br /&gt;         Update = &lt;span style="color: #006080"&gt;&amp;quot;ddd&amp;quot;&lt;/span&gt;;&lt;br /&gt;         Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;Derived class Called&amp;quot;&lt;/span&gt;);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Program&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;     {&lt;br /&gt;         IBand band = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ABand();&lt;br /&gt;         band.GetStatus();&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt; }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;We have 2 classes, Band and ABand which implement the IBand interface explicitly.&lt;br /&gt;&lt;br /&gt;Now the call to band.GetStatus in Main will display &amp;quot;Derived class called&amp;quot;. This will only happen if the Derived class (ABand) also implements the interface IBand explicitly (not in the literal sense in that it does not implement the methods using the IBand.GetStatus syntax) &lt;br /&gt;&lt;br /&gt;If the ABand class does not implement the IBand interface explicitly (but implicitly since it inherits from Band which implements IBand) then the above code will output &amp;quot;Base class called&amp;quot; &lt;br /&gt;&lt;br /&gt;However note one thing, that when the CTor for ABand is invoked it will invoke the ctor Band class and which will call GetStatus() method from within Band class hence this will output &amp;quot;Base class called&amp;quot; even though the ABand class has implemented the IBand interface explicilty.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-4916472706414653446?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/4916472706414653446/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=4916472706414653446" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4916472706414653446" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4916472706414653446" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/09/method-hiding-polymorphism-in-c.html" title="Method Hiding... Polymorphism in C#" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-3109305841424623515</id><published>2008-09-09T20:23:00.002-04:00</published><updated>2008-09-09T20:42:32.169-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LINQ" /><title type="text">Linq To XML : Check for existence of an element</title><content type="html">&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;var bookQuery = &lt;br /&gt;from book &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; bookXml.Descendants(&lt;span style="color: #006080"&gt;&amp;quot;Item&amp;quot;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;let attributes = book.Element(&lt;span style="color: #006080"&gt;&amp;quot;ItemAttributes&amp;quot;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;let price = Decimal.Parse((&lt;br /&gt;  book.Elements(&lt;span style="color: #006080"&gt;&amp;quot;OfferSummary&amp;quot;&lt;/span&gt;).Any() &lt;br /&gt;  &amp;amp;&amp;amp; book.Element(&lt;span style="color: #006080"&gt;&amp;quot;OfferSummary&amp;quot;&lt;/span&gt;).Elements(&lt;span style="color: #006080"&gt;&amp;quot;LowestNewPrice&amp;quot;&lt;/span&gt;).Any()&lt;br /&gt;  ? book.Element(&lt;span style="color: #006080"&gt;&amp;quot;OfferSummary&amp;quot;&lt;/span&gt;).Element(&lt;span style="color: #006080"&gt;&amp;quot;LowestNewPrice&amp;quot;&lt;/span&gt;).Element(&lt;span style="color: #006080"&gt;&amp;quot;Amount&amp;quot;&lt;/span&gt;).Value&lt;br /&gt;  : (attributes.Elements(&lt;span style="color: #006080"&gt;&amp;quot;ListPrice&amp;quot;&lt;/span&gt;).Any()&lt;br /&gt;      ? attributes.Element(&lt;span style="color: #006080"&gt;&amp;quot;ListPrice&amp;quot;&lt;/span&gt;).Element(&lt;span style="color: #006080"&gt;&amp;quot;Amount&amp;quot;&lt;/span&gt;).Value &lt;br /&gt;      : &lt;span style="color: #006080"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;))) / 100&lt;br /&gt;&lt;br /&gt;select &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; {Price = price};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The trick is to use the Elements(“node”) instead of Element(“node”) and then use the Any() function which will return true if an element of that name exists.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Some other LINQ tips:&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Some of the extensions that one can use are Intersect,Union &amp;amp;&amp;amp; Except &lt;br /&gt;  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;var list1 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; { 2, 4, 9, 11, 3, 6 };&lt;br /&gt;var list2 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; { 3, 8, 4, 30, 9, 16 };&lt;br /&gt;var newlist = list1.Intersect(list2);&lt;/pre&gt;&lt;br /&gt;This returns : 3,4,9&lt;br /&gt;newlist = list1.Union(list2);&lt;br /&gt;this returns : 2,3,4,6,8,9,11,16,30. finally &lt;br /&gt;newlist = list1.Except(list2);&lt;br /&gt;returns : 2,11,6&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-3109305841424623515?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/3109305841424623515/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=3109305841424623515" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3109305841424623515" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3109305841424623515" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/09/linq-to-xml-check-for-existence-of.html" title="Linq To XML : Check for existence of an element" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-8054519056156161156</id><published>2008-08-26T14:57:00.001-04:00</published><updated>2008-10-13T18:12:17.077-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">Convert Array of Ints into bytes</title><content type="html">&lt;p&gt;Here is the code to convert array of Ints to bytes:&lt;/p&gt;  &lt;div&gt;   &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;[] source = ids.ToArray();&lt;br /&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; length = source.Length * 4;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] dest = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[length];&lt;br /&gt;System.Buffer.BlockCopy(source, 0, dest, 0, dest.Length);&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-8054519056156161156?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/8054519056156161156/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=8054519056156161156" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/8054519056156161156" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/8054519056156161156" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/08/convert-array-of-ints-into-bytes.html" title="Convert Array of Ints into bytes" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-3555409414658348433</id><published>2008-07-25T12:44:00.001-04:00</published><updated>2008-10-13T18:12:25.244-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aspnet20" /><title type="text">Alternating styles in ListView- without AlternatingItemTemplate</title><content type="html">&lt;p&gt;From within any template, you have access to the current index of the row within the whole data set, using &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listviewdataitem.dataitemindex.aspx"&gt;Container.DataItemIndex&lt;/a&gt;, and within the currently displayed items, using &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listviewdataitem.displayindex.aspx"&gt;Container.DisplayIndex&lt;/a&gt;. This gives us an easy way to alternate styles:&lt;/p&gt;  &lt;pre&gt;&amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;  &amp;lt;li class=&amp;quot;&amp;lt;%# Container.DisplayIndex % 2 == 0 ? &amp;quot;even&amp;quot; : &amp;quot;odd&amp;quot; %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;%# Eval(&amp;quot;Name&amp;quot;) %&amp;gt;&lt;br /&gt;  &amp;lt;/li&amp;gt;&lt;br /&gt;&amp;lt;/ItemTemplate&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Just define the even and odd classes in your stylesheet and you're pretty much done.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-3555409414658348433?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/3555409414658348433/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=3555409414658348433" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3555409414658348433" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3555409414658348433" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/07/alternating-styles-in-listview-without.html" title="Alternating styles in ListView- without AlternatingItemTemplate" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-6547370845336329128</id><published>2008-07-24T22:53:00.001-04:00</published><updated>2008-07-24T23:01:00.687-04:00</updated><title type="text">Batch Inserts to SQL Server- Stored procedure method</title><content type="html">&lt;p&gt;To do batch Updates to SQL server &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create DataTable or DataSet and populate it with required rows &lt;/li&gt;    &lt;li&gt;Next Create a SqlCommand and SqlDataAdapter using that SqlCommand &lt;/li&gt;    &lt;li&gt;Remember to set the UpdateRowSource property on the Command the the appropriate value&lt;/li&gt;    &lt;li&gt;Set the UpdateBatchSize Property on the SqlDataAdapter &lt;/li&gt;    &lt;li&gt;then call SqlDataAdapter.Update(dt) to push the updates to SQL server &lt;/li&gt; &lt;/ul&gt;  &lt;div&gt;   &lt;div&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;DataTable dt = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataTable();&lt;br /&gt;dt.Columns.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataColumn(&lt;span style="color: #006080"&gt;&amp;quot;asin&amp;quot;&lt;/span&gt;));&lt;br /&gt;dt.Columns.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataColumn(&lt;span style="color: #006080"&gt;&amp;quot;trackasin&amp;quot;&lt;/span&gt;));&lt;br /&gt;dt.Columns.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataColumn(&lt;span style="color: #006080"&gt;&amp;quot;isrc&amp;quot;&lt;/span&gt;));&lt;br /&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i =0; i &amp;lt; 2000;i++)&lt;br /&gt;{&lt;br /&gt;    DataRow dr = dt.NewRow();&lt;br /&gt;    dr[&lt;span style="color: #006080"&gt;&amp;quot;asin&amp;quot;&lt;/span&gt;] = asin;&lt;br /&gt;    dr[&lt;span style="color: #006080"&gt;&amp;quot;trackasin&amp;quot;&lt;/span&gt;] = trackasin;&lt;br /&gt;    dr[&lt;span style="color: #006080"&gt;&amp;quot;isrc&amp;quot;&lt;/span&gt;] = isrc;&lt;br /&gt;    &lt;span style="color: #008000"&gt;//dr.RowState = DataRowState.Added;&lt;/span&gt;&lt;br /&gt;    dt.Rows.Add(dr);&lt;br /&gt;}&lt;br /&gt;------------------------------------------------&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlConnection connection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(ConfigurationManager.ConnectionStrings[&lt;span style="color: #006080"&gt;&amp;quot;MySpaceMusic&amp;quot;&lt;/span&gt;].ConnectionString))&lt;br /&gt;{&lt;br /&gt;    SqlCommand command = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlCommand(INSERT_TRACK, connection);&lt;br /&gt;    command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;    command.UpdatedRowSource = UpdateRowSource.None;&lt;br /&gt;    command.CommandTimeout = commandTimeout;&lt;br /&gt;&lt;br /&gt;    command.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@asin&amp;quot;&lt;/span&gt;, SqlDbType.VarChar, 255, dt.Columns[0].ColumnName);&lt;br /&gt;    command.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@trackAsin&amp;quot;&lt;/span&gt;, SqlDbType.VarChar, 255, dt.Columns[1].ColumnName);&lt;br /&gt;    command.Parameters.Add(&lt;span style="color: #006080"&gt;&amp;quot;@isrc&amp;quot;&lt;/span&gt;, SqlDbType.VarChar, 600, dt.Columns[2].ColumnName);&lt;br /&gt;&lt;br /&gt;    SqlDataAdapter adpt = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlDataAdapter();&lt;br /&gt;&lt;br /&gt;    adpt.InsertCommand = command;&lt;br /&gt;    adpt.UpdateBatchSize = batchSize;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        connection.Open();&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; recordsInserted = adpt.Update(dt);&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;finally&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        adpt.Dispose();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-6547370845336329128?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/6547370845336329128/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=6547370845336329128" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/6547370845336329128" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/6547370845336329128" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/07/batch-inserts-to-sql-server-stored.html" title="Batch Inserts to SQL Server- Stored procedure method" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-1798885924883133403</id><published>2008-07-03T01:42:00.002-04:00</published><updated>2008-07-03T01:44:53.424-04:00</updated><title type="text">क्यूट सोंग .. नानी तेरी मोरनी को मोर ले गए</title><content type="html">Naani Teri Morni Ko Mor Le Gaye &lt;br /&gt;Baaki Jo Bacha Tha Kaale Chor Le Gaye&lt;br /&gt;&lt;br /&gt; Khaake Peeke Mote Hoke, &lt;br /&gt;Chor Baithe Rail Mein &lt;br /&gt;Choron Vaala Dibba Kat Ke, Pahuncha Seedhe Jail Mein &lt;br /&gt;&lt;br /&gt;Naani Teri Morni Ko... &lt;br /&gt;&lt;br /&gt;Un Choron Ki Khoob Khabar Li, &lt;br /&gt;Mote Thaanedaar Ne &lt;br /&gt;Moron Ko Bhi Khoob Nachaaya, &lt;br /&gt;Jungal Ki Sarkaar Ne &lt;br /&gt;&lt;br /&gt;Naani Teri Morni Ko... &lt;br /&gt;Achhi Naani Pyaari Naani, &lt;br /&gt;Roosa-Roosi Chhod De Jaldi Se Ek Paisa De De, &lt;br /&gt;Tu Kanjoosi chod de...&lt;br /&gt;&lt;br /&gt;Nani teri morni ko chor le gaye&lt;br /&gt;baaki jo bacha tha kaale chor le gaye&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-1798885924883133403?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/1798885924883133403/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=1798885924883133403" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/1798885924883133403" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/1798885924883133403" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/07/blog-post.html" title="क्यूट सोंग .. नानी तेरी मोरनी को मोर ले गए" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-4999513503733434952</id><published>2008-05-06T01:56:00.001-04:00</published><updated>2008-05-06T01:56:54.211-04:00</updated><title type="text">Unity Application block and Generic Singleton</title><content type="html">&lt;p&gt;Here are some features of the Unity Application block. (Note there is overhead in using this block&amp;#8230; i.e. overhead while creating instances of objects that have dependent objects)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc440954.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc440954.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160; Highlights of the Unity Application Block &lt;/p&gt;  &lt;p&gt;&lt;a name="sectionToggle2"&gt;&lt;/a&gt;&lt;a name="intro_highlights"&gt;&lt;/a&gt;The Unity Application Block includes the following features:&lt;/p&gt;  &lt;p&gt;&amp;#183; It provides a mechanism for building (or assembling) instances of objects, which may contain other dependent object instances. &lt;/p&gt;  &lt;p&gt;&amp;#183; It exposes &lt;b&gt;RegisterType&lt;/b&gt; methods that support configuring the container with type mappings and objects (&lt;b&gt;including singleton instances&lt;/b&gt;) and &lt;b&gt;Resolve&lt;/b&gt; methods that return instances of built objects that can contain any dependent objects. &lt;/p&gt;  &lt;p&gt;&amp;#183; It provides inversion of control (IoC) functionality by allowing injection of preconfigured objects into classes built by the application block. Developers can specify an interface or class type in the constructor (constructor injection) or apply to properties and methods attributes to initiate property injection and method call injection. &lt;/p&gt;  &lt;p&gt;&amp;#183; It supports a hierarchy for containers. A container may have child container(s), allowing object location queries to pass from the child out through the parent container(s). &lt;/p&gt;  &lt;p&gt;&amp;#183; &lt;b&gt;It can read configuration information from standard configuration systems, such as XML files, and use it to configure the containe&lt;/b&gt;r( The Unity Container which hold references to the objects built using Resolve method). &lt;/p&gt;  &lt;p&gt;&amp;#183; It makes no demands on the object class definition. There is no requirement to apply attributes to classes (except when using property or method call injection), and there are no limitations on the class declaration. &lt;/p&gt;  &lt;p&gt;&amp;#183; It supports custom container extensions that developers can implement; for example, methods to allow additional object construction and container features such as caching. &lt;/p&gt;  &lt;p&gt;And here is the code for the Generic Singleton:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;/// Provides a Singleton implementation using Generics.&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;/// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;Type of singleton instance&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Singleton&amp;lt;T&amp;gt; &lt;span class="kwrd"&gt;where&lt;/span&gt; T : &lt;span class="kwrd"&gt;new&lt;/span&gt;()&lt;br /&gt;        {&lt;br /&gt;            Singleton() { }&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; T Instance&lt;br /&gt;            {&lt;br /&gt;                get&lt;br /&gt;                { &lt;span class="kwrd"&gt;return&lt;/span&gt; Nested.instance; }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;             &lt;span class="kwrd"&gt;class&lt;/span&gt; Nested&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="rem"&gt;// Explicit static constructor to tell C# compiler&lt;/span&gt;&lt;br /&gt;                &lt;span class="rem"&gt;// not to mark type as beforefieldinit&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;static&lt;/span&gt; Nested() { }&lt;br /&gt;                &lt;span class="kwrd"&gt;internal&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; T instance = &lt;span class="kwrd"&gt;new&lt;/span&gt; T();&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The code for returning the instance then becomes:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; BlogSettings Instance&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; Utils.Singleton&amp;lt;BlogSettings&amp;gt;.Instance;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;You have to also change the constructor for BlogSettings to public to allow this this to work&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-4999513503733434952?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/4999513503733434952/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=4999513503733434952" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4999513503733434952" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4999513503733434952" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/05/unity-application-block-and-generic.html" title="Unity Application block and Generic Singleton" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-816999454005132499</id><published>2008-04-30T17:03:00.001-04:00</published><updated>2008-04-30T17:03:25.225-04:00</updated><title type="text">Debugging Win Service</title><content type="html">&lt;p&gt;For debugging a Startup of Windows Service add the call to the Method Debugger.Launch or Debugger.Break. This call can be placed in the Constructor of the Service.cs or in the first line of the OnStart() method.&lt;/p&gt;  &lt;p&gt;Calling &lt;a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.launch.aspx"&gt;Debugger.Launch()&lt;/a&gt; or &lt;a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx"&gt;Debugger.Break()&lt;/a&gt; in your code allow you to debug such problems.&lt;/p&gt;  &lt;p&gt;For debugging an already running WindowService, simply attach the Debugger to to an existing process using &amp;quot;Debug\Attach to Process&amp;quot; menu item in VS 2005/VS 2008.&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Visual Linq&lt;/b&gt; is a tool to visually create your Linq to SQL queries: &lt;a href="http://code.msdn.microsoft.com/vlinq"&gt;http://code.msdn.microsoft.com/vlinq&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;hr /&gt;&lt;strong&gt;A Primer on WCF :&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;It is all about Service Contracts, Operation Contracts, Data Contracts and Fault Contracts and other type of Contracts&lt;/p&gt;  &lt;p&gt;Contracts usually enforced on Interfaces and the Classes then implement these interfaces.&lt;/p&gt;  &lt;p&gt;If Service Contract, Operation Contract attributes are applied to classes then we have an additional advantage that the methods can be marked private and can still be accessed by WCF clients.&lt;/p&gt;  &lt;p&gt;DataContracts are used to create .NET objects that can be sent to/fro between the client and the WCF Service. thus the DataMember attribute tells the runtime which properties need to be serialized/deserialized by the framework before being passed onto the network.&lt;/p&gt;  &lt;p&gt;We dont need DataContracts for Intrinsic objects like Int32, string etc since they are natively serializable&lt;/p&gt;  &lt;p&gt;FaultContracts can be applied to methods and can be used by the Client to determine what exceptions occurred at the server during processing of the request. Thus .NET exceptions are converted to FaultExceptions which are then sent over the wire as SOAP faults and then the client can reconstruct them to extract the Fault Detail from the FaultException&lt;/p&gt;  &lt;p&gt;A good introduction to WCF can be found here: &lt;a href="http://www.google.com/url?sa=t&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fwww.davidchappell.com%2FIntroducingWCFv1.2.1.pdf&amp;amp;ei=VdoYSNOdC4eSpwTXsfn6CA&amp;amp;usg=AFQjCNEnWg_BM0dLR9CuADbAvauWCf8gRw&amp;amp;sig2=1_j4m4Z53P2ZviBr-MLTQQ" target="_blank"&gt;David Chappell's intro to WCF&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Bindings and endpoints form the heart of WCF, we can have different kinds of bindings, &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;BasicHTTPBinding which allows Http and HTTPS access.&lt;/li&gt;    &lt;li&gt;WSHttpBinding which adds the WS specifications to the binding to provide for reliability, transactions, security and other features.&lt;/li&gt;    &lt;li&gt;WSDualHttpBinding: use this for two-way communication between client and service, only HTTP is supported&lt;/li&gt;    &lt;li&gt;FederatedBinding: which means that if authenticated by one of the services, then the same ticket can be used to authenticate the client to other WCF/Java services&lt;/li&gt;    &lt;li&gt;NETTCPBinding : used when communicating using TCP protocol as the transport&lt;/li&gt;    &lt;li&gt;NamedPipeBinding: used within the local machine for inter process communication on the same machine.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Endpoints define how the service can be accessed by the client. Each WCF Service exposes endpoints to clients to publicize their services. Specify a different endpoint for each binding used by your service, thus the same machine can expose the service over HTTP and TCP using basicHttpBinding and NetTcpBinding respoectively and thus exposing endpoints for each of them. Endpoints consist of address, behavior etc&lt;/p&gt;  &lt;p&gt;John Sharp's &lt;a href="http://www.google.com/url?sa=t&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fwww.microsoft.com%2FMSPress%2Fbooks%2F10022.aspx&amp;amp;ei=Ut4YSI-iDJaEpASp49mHCQ&amp;amp;usg=AFQjCNGU1QKlIIpmhqHFpMyzfbXMFn8_WA&amp;amp;sig2=Rv8g7Nv_ujiU_xkKA9HSPw" target="_blank"&gt;WCF Step by Step from Microsoft Press&lt;/a&gt; is an excellent book to get started.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-816999454005132499?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/816999454005132499/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=816999454005132499" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/816999454005132499" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/816999454005132499" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/04/debugging-win-service.html" title="Debugging Win Service" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-9010650091937342799</id><published>2008-04-06T19:31:00.001-04:00</published><updated>2008-04-06T19:31:22.811-04:00</updated><title type="text">Get back almost 1GB of free disk space after Vista SP1 installation</title><content type="html">&lt;p&gt;If you have installed SP1 of Vista you certainly recognized that your drive lost around 1Gb of free space. &lt;/p&gt;  &lt;p&gt;The solution is to use a tool that comes with the SP1 to recover your free space at the price of not being able to come back and uninstall the SP1. &lt;/p&gt;  &lt;p&gt;This tool is vsp1cln.exe that you can run like this:&lt;/p&gt; &lt;a href="http://lh3.google.com/rbg.net/R_ldSXrg4aI/AAAAAAAAAGU/EjeUGPgwBBg/vistasp1%5B5%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="256" alt="vistasp1" src="http://lh4.google.com/rbg.net/R_ldSnrg4bI/AAAAAAAAAGc/XF_bxOtAGbs/vistasp1_thumb%5B3%5D.jpg" width="643" border="0" /&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-9010650091937342799?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/9010650091937342799/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=9010650091937342799" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/9010650091937342799" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/9010650091937342799" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/04/get-back-almost-1gb-of-free-disk-space_06.html" title="Get back almost 1GB of free disk space after Vista SP1 installation" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-2750246316829155239</id><published>2008-03-27T14:18:00.000-04:00</published><updated>2008-03-27T14:18:16.286-04:00</updated><title type="text">Add Windows Explorer to your Visual Studio tools menu</title><content type="html">&lt;a href="http://dotnettipoftheday.org/tips/explorer-in-tools-menu.aspx"&gt;.NET Tip of The Day: Add Windows Explorer to your Visual Studio tools menu&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-2750246316829155239?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="related" href="http://dotnettipoftheday.org/tips/explorer-in-tools-menu.aspx" title="Add Windows Explorer to your Visual Studio tools menu" /><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/2750246316829155239/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=2750246316829155239" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/2750246316829155239" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/2750246316829155239" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/03/add-windows-explorer-to-your-visual.html" title="Add Windows Explorer to your Visual Studio tools menu" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-958909116162644343</id><published>2008-03-03T20:41:00.001-05:00</published><updated>2008-10-13T18:33:32.405-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PFX" /><title type="text">Concurrency and Co-ordination Runtime - CCR</title><content type="html">&lt;p&gt;Pretty cool Library from Microsoft for performing concurrent operations like multithreading operations and async tasks. Essenitally you get a guide to migrate all your APM ( Asynchronous Programming Model) tasks to the CCR tasks so that synchronization and co-ordination issues are automatically handled for you behind the scenes. &lt;/p&gt;  &lt;p&gt;Some of the good links on CCR are: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1424&amp;amp;SiteID=1"&gt;MSDN Forum&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&amp;#160;&lt;a href="http://iodyne.blogspot.com/"&gt;Nick Gunn's blog&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.google.com/url?sa=t&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fmsdn.microsoft.com%2Fmsdnmag%2Fissues%2F06%2F09%2FConcurrentAffairs%2Fdefault.aspx&amp;amp;ei=M2TMR-eJMIvApgSJpbj0Dw&amp;amp;usg=AFQjCNE-2O20FgjyrAHfmu7SMvHP5ux8eg&amp;amp;sig2=uZMQhxusI2JZL9WwMtqlkA"&gt;Jeffrey Richters MSDN Magazine article&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.ConcurrencyRuntime"&gt;Channel 9 link&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-958909116162644343?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/958909116162644343/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=958909116162644343" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/958909116162644343" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/958909116162644343" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/03/concurrency-and-co-ordination-runtime.html" title="Concurrency and Co-ordination Runtime - CCR" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-4791155007989662956</id><published>2008-02-08T11:29:00.000-05:00</published><updated>2008-10-13T18:33:39.184-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aspnet20" /><title type="text">ASP.NET State Server and Load Balancer</title><content type="html">These are great links:&lt;br /&gt;&lt;a href="http://blog.maartenballiauw.be/post/2007/11/ASPNET-load-balancing-and-ASPNET-state-server-(aspnet_state).aspx"&gt;ASP.NET load balancing and ASP.NET state server (aspnet_state)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://weblogs.asp.net/joestagner/archive/2008/01/31/maarten-balliauw-on-asp-net-load-balancing-and-the-asp-net-state-server.aspx"&gt;Session state ...State Server&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-4791155007989662956?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/4791155007989662956/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=4791155007989662956" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4791155007989662956" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/4791155007989662956" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/02/aspnet-state-server-and-load-balancer.html" title="ASP.NET State Server and Load Balancer" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-9190680612667432911</id><published>2008-01-09T15:40:00.000-05:00</published><updated>2008-01-09T15:45:46.146-05:00</updated><title type="text">How to check email works with no SMTP</title><content type="html">There is a way to send e-mails with no SMTP server set up. Just configure your .NET application to drop e-mails into a specified folder instead of sending them via SMTP server&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1   &amp;lt;\cf3 system.net\cf1 &amp;gt;\par ??    &amp;lt;\cf3 mailSettings\cf1 &amp;gt;\par ??      &amp;lt;\cf3 smtp\cf1  \cf4 deliveryMethod\cf1 =\cf0 "\cf1 SpecifiedPickupDirectory\cf0 "\cf1 &amp;gt;\par ??        &amp;lt;\cf3 specifiedPickupDirectory\cf1  \cf4 pickupDirectoryLocation\cf1 =\cf0 "\cf1 c:\\Rohit\\\cf0 "\cf1  /&amp;gt;\par ??      &amp;lt;/\cf3 smtp\cf1 &amp;gt;\par ??    &amp;lt;/\cf3 mailSettings\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 system.net\cf1 &amp;gt;}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;system.net&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;mailSettings&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;smtp&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;deliveryMethod&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SpecifiedPickupDirectory&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;specifiedPickupDirectory&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;pickupDirectoryLocation&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;c:\Rohit\&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;smtp&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;mailSettings&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;system.net&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This will instruct SmtpClient class to generate mail message, save it as .eml file and drop it into c:\Test\ folder&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-9190680612667432911?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/9190680612667432911/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=9190680612667432911" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/9190680612667432911" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/9190680612667432911" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/01/how-to-check-email-works-with-no-smtp.html" title="How to check email works with no SMTP" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-3305007966524727418</id><published>2008-01-08T10:20:00.000-05:00</published><updated>2008-01-08T10:22:12.316-05:00</updated><title type="text">Using CompareValidator for just Data Validation</title><content type="html">&lt;strong&gt;A simple method to validate an integer, double, date, or currency values entered into a textbox on ASP.NET page &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Normally the CompareValidator is used to check one value against another on ASP.NET page. However it also can be used to ensure user has entered data in a correct format. (Data Validation)&lt;br /&gt;&lt;br /&gt;Here's how it works:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Set the ControlToValidate property to the ID of the TextBox. &lt;/li&gt;&lt;li&gt;Set the Operator property to DataTypeCheck. &lt;/li&gt;&lt;li&gt;Assign a ValidationDataType enumeration member to the Type property, which includes either one of the following : String, Integer, Double, Date, and Currency. &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-3305007966524727418?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/3305007966524727418/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=3305007966524727418" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3305007966524727418" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/3305007966524727418" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/01/using-comparevalidator-for-just-data.html" title="Using CompareValidator for just Data Validation" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4971377397859266634.post-5630965137964590035</id><published>2008-01-03T09:36:00.000-05:00</published><updated>2008-10-13T18:33:59.479-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="XML" /><title type="text">using FOR XMLPATH to concat multiple row values</title><content type="html">The need is to concatenate multiple row values from a table&lt;br /&gt;The following TSQL in SQL 2005 can assist in returning values&lt;br /&gt;&lt;br /&gt;Following is the input table&lt;br /&gt;ID Value&lt;br /&gt;---------&lt;br /&gt;1 '-'&lt;br /&gt;1 'C'&lt;br /&gt;1 'B'&lt;br /&gt;1 'A'&lt;br /&gt;2 '='&lt;br /&gt;2 'G'&lt;br /&gt;2 'D'&lt;br /&gt;=======&lt;br /&gt;Expected output :&lt;br /&gt;ID Concat&lt;br /&gt;1 '-CBA'&lt;br /&gt;2 '=GD'&lt;br /&gt;=================&lt;br /&gt;&lt;br /&gt;TSQL for this :&lt;br /&gt;select Distinct ID, o.List&lt;br /&gt;from &lt;br /&gt;#t1 A&lt;br /&gt;CROSS APPLY&lt;br /&gt;(&lt;br /&gt; select Val as [text()] from #t1 B&lt;br /&gt; where B.ID = A.ID&lt;br /&gt; FOR XML PATH('')&lt;br /&gt;) o (List)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4971377397859266634-5630965137964590035?l=rbgupta.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://rbgupta.blogspot.com/feeds/5630965137964590035/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=4971377397859266634&amp;postID=5630965137964590035" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/5630965137964590035" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4971377397859266634/posts/default/5630965137964590035" /><link rel="alternate" type="text/html" href="http://rbgupta.blogspot.com/2008/01/using-for-xmlpath-to-concat-multiple.html" title="using FOR XMLPATH to concat multiple row values" /><author><name>Rohit Gupta</name><uri>http://www.blogger.com/profile/08950669136315735108</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="10617503206511730333" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry></feed>
