<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Data and Business Logic Development</title>
        <link>http://community.dotnetwork.it/Excentric/category/73.aspx</link>
        <description>Data and Business Logic Development </description>
        <language>en-US</language>
        <copyright>Sabrina C.</copyright>
        <managingEditor>ziayeye@ziayeye.it</managingEditor>
        <generator>Subtext Version 1.9.5.176</generator>
        <item>
            <title>Work with a simple HTTP Listener and avoid problems with BOM</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/10/09/work-with-a-simple-http-listener-and-avoid-problems-with.aspx</link>
            <description>&lt;p&gt;We are implementing an internal service (internal means that it runs on an intranet) for one of our softwares that exchanges messages with my application clients when they run on the users machines. The data exchanged is sent as an XML class to an HTTP Listener. &lt;/p&gt;  &lt;p&gt;It looked all simple and easy except that, when the XML class arrived to the Listener, the XML De-Serializer went nuts telling us the class was not correctly formatted.&lt;/p&gt;  &lt;p&gt;After some checks to verify if we did something wrong (I always start from the principle that the probability I make a mess is higher than the one that compiler or libraries from third parties are wrong) and not finding nothing in the serialization and deserialization routines, sniffing the data arriving in the request, we discovered that the serialized data got 3 bytes preceding the &amp;lt;?xml which starts every xml data, in Hexadecimal EB BB BF, we didn’t understand what it was, and after a moment thinking to what could be wrong in our code to produce such problem, we made a search through the internet and learn something important (as always you never stop learning things…) Anyway, we discovered these three characters are a BOM (Byte order Mark) that is automatically added by the system serializing in UTF-8 encoding. Notepad, Notepad++ and other text editors/readers ignore it so you never notice it’s existence, but it is there. The problem in my service was that when deserializing from a string the three characters were not discarded so the Deserialize method gave an error telling that it found bad characters at the beginning of the class.&lt;/p&gt;  &lt;p&gt;Is there a way to avoid the problem with BOM? Yes, it is one of the parameters of the &lt;font color="#00df38"&gt;&lt;strong&gt;XmlWriterSettings&lt;/strong&gt;&lt;/font&gt; &lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;XmlWriterSettings xstt = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlWriterSettings();

xstt.Encoding = Encoding.UTF8 : &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8Encoding(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
&lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlWriter writer = XmlWriter.Create(stream, xstt))
{
   ...
}&lt;/pre&gt;

&lt;p&gt;Using this option to serialize the class avoids the BOM and the deserialization problems. &lt;/p&gt;

&lt;p&gt;Hoping to help someone else solving this problem faster &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Occhiolino" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/d833b34e42a0_BE20/wlEmoticon-winkingsmile_2.png" /&gt;&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/894.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/10/09/work-with-a-simple-http-listener-and-avoid-problems-with.aspx</guid>
            <pubDate>Sun, 09 Oct 2011 19:49:47 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/894.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/10/09/work-with-a-simple-http-listener-and-avoid-problems-with.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/894.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Working with XML part 2</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/11/01/working-with-xml-part-2.aspx</link>
            <description>&lt;h3&gt;What the system offers for free&lt;/h3&gt;
&lt;p&gt;As I explained in previous post, .NET is very XML friendly, so it gives us a few base functionalities to avoid us doing things already done, here we say it saves us from inventing hot water. To demostrate the basic functionalities I build a simple, fundamentally useless class that demonstrates us how the basic data types of .NET are all serializable.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;
&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; DnwEnitities.Entities
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Serializzabile
    {

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Serializzabile()
        {
            TheChar = &lt;span class="str"&gt;'A'&lt;/span&gt;;
            TheByte = 10;
            TheBool = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            TheShort = 100;
            TheInt = 1000;
            TheLong = 1000000;
            TheFloat = 1234.7899f;
            TheDouble = 9800000.89600;
            TheDecimal = 766000000.654390001m;
            TheString = &lt;span class="str"&gt;"The string is very nice and useful."&lt;/span&gt;;
            TheDate = DateTime.Now;
            TheGuid = Guid.NewGuid();
            TheEnum = SerializableEnum.ALot;
        }
    
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;char&lt;/span&gt; TheChar
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; TheByte
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; TheBool
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;short&lt;/span&gt; TheShort
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; TheInt
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; TheLong
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; TheFloat
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; TheDouble
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; TheDecimal
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; TheString
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; DateTime TheDate
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Guid TheGuid
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; SerializableEnum TheEnum
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Serializzabile ReadXml(&lt;span class="kwrd"&gt;string&lt;/span&gt; pSerializedData, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pIsXmlData)
        {
            Serializzabile retP = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!pIsXmlData)
            {
                retP = (Serializzabile)SerializeHelper.DeserializeFromFile(&lt;br /&gt;                   &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Serializzabile), pSerializedData);
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {
                retP = (Serializzabile)SerializeHelper.DeserializeFromString(&lt;br /&gt;                   &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Serializzabile), pSerializedData);
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (retP);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; WriteXml(&lt;span class="kwrd"&gt;string&lt;/span&gt; pFileName)
        {
            SerializeHelper.SerializeToFile(pFileName, &lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Serializzabile), &lt;span class="kwrd"&gt;false&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; WriteXml()
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (SerializeHelper.SerializeToString(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;false&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty));
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ToString()
        {
            StringBuilder sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();
            sb.AppendFormat(&lt;span class="str"&gt;"Char: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheChar);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Byte: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheByte);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Bool: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheBool);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Short: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheShort);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Int: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheInt);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Long: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheLong);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Float: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheFloat);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Double: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheDouble);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Decimal: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheDecimal);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"String: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheString);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Date: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheDate);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Guid: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheGuid);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Enum: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheEnum);
            sb.AppendLine();
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (sb.ToString());
        }

    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; SerializableEnum : &lt;span class="kwrd"&gt;int&lt;/span&gt;
    {
        None = 0,
        All,
        Some,
        ALot
    }
    
}&lt;/pre&gt;
&lt;p&gt;This class represents the most raw and simple entity, it contains some public properties, one for each of the base data in .NET, it contains the WriteXml and ReadXml methods, using our Helper to write and read in XML the content of the class and an override of the ToString method that helps us visualize the class contents. There is also a simple Enumeration, showing us that enumerable values are serialized automatically.&lt;/p&gt;
&lt;p&gt;Instantiating a class of Serializzabile type, and calling its WriteXml method to write its content to a file, the content of the file is the &lt;br /&gt;
following:&lt;/p&gt;
&lt;pre class="HtmlFormat"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Serializzabile&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsi&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="attr"&gt;     xmlns:xsd&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/2001/XMLSchema"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheChar&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;65&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheChar&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheByte&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheByte&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheBool&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheBool&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheShort&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;100&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheShort&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheInt&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheInt&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheLong&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1000000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheLong&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheFloat&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1234.78992&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheFloat&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheDouble&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;9800000.896&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheDouble&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheDecimal&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;766000000.654390001&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheDecimal&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheString&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;The string is very nice and useful.&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheString&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheDate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;2010-11-01T09:26:13.331+01:00&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheDate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheGuid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;3da90b04-ec02-4308-a177-fc6723ab8aa9&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheGuid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheEnum&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;ALot&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheEnum&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Serializzabile&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Using the ReadXml  to re-read the class, we will obtain an equivalent object. If we haven’t any particular requirement to satisfy in our programs, this is the simplest way to build a serializable entity.&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f9cef952-a247-40e7-af19-b96c7a17cc4a" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/XML" rel="tag"&gt;XML&lt;/a&gt;,&lt;a href="http://technorati.com/tags/entities" rel="tag"&gt;entities&lt;/a&gt;,&lt;a href="http://technorati.com/tags/serialization" rel="tag"&gt;serialization&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/545.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/11/01/working-with-xml-part-2.aspx</guid>
            <pubDate>Mon, 01 Nov 2010 09:04:25 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/545.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/11/01/working-with-xml-part-2.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/545.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Working with XML part 1</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/10/31/working-with-xml-part-1.aspx</link>
            <description>&lt;p&gt;This is the first of a small series of posts dedicated to XML serialization, publishing the code I used for the last Workshop we did last month. I’ll start from the serialization Helper class, already discussed in the past, now revised for Framework 4.0.&lt;/p&gt;  &lt;p&gt;To persist on a disk a C# (orVB) class, you need to create it with some simple tricks to make it serializable. Serialization is a word I’ve started to listen around 2003 at the first conferences on .NET I attended to. Maybe it’s self explanatory for an English mother tongue, but it wasn’t for me. I needed a while to understand that Serialization is the way to persist on mass storage the state of an object to be able to rebuild the same object with the exactly same state as the one we persisted on disk.&lt;/p&gt;  &lt;p&gt;Entity classes are classes with no particular abilities, they are defined this way because they represent structured data, so entities are the classes representing a Data Model, it can be simple and persisted on a file, or complex, like a LinqToSql or EntityFramework model persisted on a database. Entities are the kind of class we will surely serialize someway.&lt;/p&gt;  &lt;p&gt;In .NET, you can serialize data in 2 ways, binary serialization and XML serialization. All the base data types in .NET are serializable, so any class containing only this kind of data, can be directly serialized with no particular modification except it needs to implement a parameterless constructor.&lt;/p&gt;  &lt;p&gt;What is automatically serialized by .NET in an object? The public properties. Why only these? I think it is because they represent the state of the object as it can be observed by who instantiated it, we can always modify the standard behaviour overriding the default serialization. In these articles we will however show only how to use the standard serialization and how to drive it how we desire just using a few simple functionalities given us by the framework itself.&lt;/p&gt;  &lt;h3&gt;SerializeHelper class&lt;/h3&gt;  &lt;p&gt;This class provides all serialization services for simple object and composite objects (collections or classes containing other classes). It uses the classes of the System.Xml and System.Xml.Serialization namespaces. Let’s see its methods.&lt;/p&gt;  &lt;h4&gt;BuildReader&lt;/h4&gt;  &lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XmlTextReader BuildReader(&lt;span class="kwrd"&gt;string&lt;/span&gt; pXmlString)
        {
            NameTable nt = &lt;span class="kwrd"&gt;new&lt;/span&gt; NameTable();
            XmlNamespaceManager nsmgr = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlNamespaceManager(nt);
            nsmgr.AddNamespace(&lt;span class="str"&gt;"bk"&lt;/span&gt;, &lt;span class="str"&gt;"urn:sample"&lt;/span&gt;);

            XmlParserContext context = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlParserContext(&lt;span class="kwrd"&gt;null&lt;/span&gt;, nsmgr, &lt;span class="kwrd"&gt;null&lt;/span&gt;, XmlSpace.None);

            &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(pXmlString, XmlNodeType.Element, context));
        }&lt;/pre&gt;

&lt;p&gt;This first method, as it's name says, creates an XmlTextReader, that together with the correspondent XmlTextWriter are the base streams for reading and writing XML data. The method above has been designed to allow us to transform a string (such as a database field) in an Xml stream. The method generates a “fake” context to build the XmlTextReader to transform the string in a stream.&lt;/p&gt;

&lt;h4&gt;DeserializeFromString&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromString(Type pTypeToDeserialize, &lt;span class="kwrd"&gt;string&lt;/span&gt; pXmlString)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader xr = BuildReader(pXmlString))
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize);
                ret = serializer.Deserialize(xr);
                xr.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromString(Type pTypeToDeserialize, &lt;br /&gt;               Type[] pExtraTypes, &lt;span class="kwrd"&gt;string&lt;/span&gt; pXmlString)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader xr = BuildReader(pXmlString))
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize, pExtraTypes);
                ret = serializer.Deserialize(xr);
                xr.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }&lt;/pre&gt;

&lt;p&gt;These two methods, one built for a class with only simple objects, another for a class with complex data types, use the previous method to create a stream that is then passed to the XmlSerializer class to get the object from the persisted string.&lt;/p&gt;

&lt;h4&gt;DeserializeFromFile&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromFile(Type pTypeToDeserialize, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPath)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlTextReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(pPath))
            {
                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize);
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per leggere i dati dal formato XML&lt;/span&gt;
                ret = serializer.Deserialize(reader);
                reader.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromFile(Type pTypeToDeserialize, &lt;br /&gt;            Type[] pExtraTypes, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPath)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlTextReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(pPath))
            {
                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize, pExtraTypes);
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per leggere i dati dal formato XML&lt;/span&gt;
                ret = serializer.Deserialize(reader);
                reader.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }&lt;/pre&gt;

&lt;p&gt;The deserialization from a file is simpler, because XmlTextReader has a constructor that builds it from a file path. The two overloads of this method allow us to specify to the XmlSerializer the classes used if the objects involved are not simple classes. We will see it’s use when we will deserialize collections, but collections are not the only complex classes we will see.&lt;/p&gt;

&lt;h4&gt;SerializeToFile&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SerializeToFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; pPath, &lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, &lt;br /&gt;          Type pTypeToSerialize, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            FileInfo fInfo = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(pPath);
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Directory.Exists(fInfo.DirectoryName))
            {
                Directory.CreateDirectory(fInfo.DirectoryName);
            }            
            &lt;span class="kwrd"&gt;using&lt;/span&gt;(XmlTextWriter writer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextWriter(pPath, Encoding.UTF8))
            {
                &lt;span class="rem"&gt;// write a readable file&lt;/span&gt;
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;

                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToSerialize);
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per persistere i dati&lt;/span&gt;
                serializer.Serialize(writer, pObjToSerialize, ns);
                writer.Close();
            }
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SerializeToFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; pPath, &lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, 
            Type pTypeToSerialize, Type[] pExtraTypes, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            FileInfo fInfo = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(pPath);
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Directory.Exists(fInfo.DirectoryName))
            {
                Directory.CreateDirectory(fInfo.DirectoryName);
            }            
            &lt;span class="kwrd"&gt;using&lt;/span&gt;(XmlTextWriter writer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextWriter(pPath, Encoding.UTF8))
            {
                &lt;span class="rem"&gt;// write a readable file&lt;/span&gt;
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;
                &lt;span class="rem"&gt;//writer.Settings.OutputMethod = XmlOutputMethod.&lt;/span&gt;
                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToSerialize, pExtraTypes);
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per persistere i dati&lt;/span&gt;
                serializer.Serialize(writer, pObjToSerialize, ns);
                writer.Close();
            }
        }&lt;/pre&gt;

&lt;p&gt;For the serialization, we made the two overloads with informations on the classes and we added a few parameters that allow us to format the classes, pNoNamespaces and pPrefix.&lt;/p&gt;

&lt;p&gt;In the code we can see how, creating the XmlTextWriter we can decide the Encoding used for the generated string, our method uses UTF8 standard serialization but if we need something else we can use another encoding. We can also control the Xml File formatting both using the Formatting Property and some other properties to determine indentation and indentation character.&lt;/p&gt;

&lt;p&gt;The use of XmlSerializerNamespaces allows us to avoid the verbose series of the namespaces inserted automatically in the first element of a serialized class:&lt;/p&gt;

&lt;p&gt;&amp;lt;Serializzabile xmlns:xsi="&lt;a href="http://www.w3.org/2001/XMLSchema-instance&amp;quot;"&gt;http://www.w3.org/2001/XMLSchema-instance"&lt;/a&gt; xmlns:xsd="&lt;a href="http://www.w3.org/2001/XMLSchema&amp;quot;"&gt;http://www.w3.org/2001/XMLSchema"&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;Replacing this with:&lt;/p&gt;

&lt;p&gt;&amp;lt;Competences xmlns="&lt;a href="http://www.dotnetwork.it&amp;quot;"&gt;http://www.dotnetwork.it"&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;Or, using the Nonamespace flag:&lt;/p&gt;

&lt;p&gt;&amp;lt;Competences&amp;gt;&lt;/p&gt;

&lt;p&gt;“killing” the namespaces is opportune to create neutral classes for data exchange between different companies and softwares, while if we want to be sure that our own classes are marked specifically to make them unique, we can add our namespace (usually it is the domain name of our website).&lt;/p&gt;

&lt;p&gt;the pPrefix parameter has instead the purpouse to allow us to set a prefix on the name of our classes to obtain the following effect:&lt;/p&gt;

&lt;p&gt;&amp;lt;dnw:Programmer xmlns:dnw="&lt;a href="http://www.dotnetwork.it"&gt;http://www.dotnetwork.it"&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;dnw:Skills&amp;gt;&lt;/p&gt;

&lt;p&gt;It allows us to specify in detail the use of our own objects without a full namespace attribute on each of them.&lt;/p&gt;

&lt;h4&gt;SerializeToString&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SerializeToString(&lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, &lt;br /&gt;            Type[] pExtraTypes, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            &lt;span class="kwrd"&gt;string&lt;/span&gt; ret = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream())
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pObjToSerialize.GetType(), pExtraTypes);
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                serializer.Serialize(stream, pObjToSerialize, ns);
                ret = Encoding.UTF8.GetString(stream.ToArray());
                stream.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SerializeToString(&lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            &lt;span class="kwrd"&gt;string&lt;/span&gt; ret = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream())
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pObjToSerialize.GetType());
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                serializer.Serialize(stream, pObjToSerialize, ns);
                ret = Encoding.UTF8.GetString(stream.ToArray());
                stream.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }&lt;/pre&gt;

&lt;p&gt;The last method, with two overloads, allows us the Xml serialization of an object on a string instead of serializing it on a file stream. To be able to do so we need however a stream, we use the MemoryStream to avoid a file on disk, the Xml generation remain identical to the one that builds a file on disk.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:34aabb1a-0e90-48b7-8fd8-a98914f96dc4" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Xml" rel="tag"&gt;Xml&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Serializzazione" rel="tag"&gt;Serializzazione&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Helper" rel="tag"&gt;Helper&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/540.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/10/31/working-with-xml-part-1.aspx</guid>
            <pubDate>Sun, 31 Oct 2010 22:46:43 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/540.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/10/31/working-with-xml-part-1.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/540.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Collection and predicates search elements without cycling</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/13/collection-and-predicates-search-elements-without-cycling.aspx</link>
            <description>&lt;p&gt;Among the most useful things when you work with collections, are Search methods, allowing us to find an element inside the collection using the value of one or more of his properties as a search criteria.&lt;/p&gt;  &lt;p&gt;These methods can be implemented both as Indexer (a property) or a specific method. The second option is necessary because often there are more properties of the same data type used to search a collection and you can implement only one indexer with a certain signature.&lt;/p&gt;  &lt;p&gt;Let’s work through some samples to see how to use predicates:&lt;/p&gt;  &lt;p&gt;Our Entity class, named AnagraficaAzienda, exposes the following properties:&lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; DescrizioneRicerca //SearchDescription
&lt;span class="kwrd"&gt;string&lt;/span&gt; RagioneSociale //Company name
&lt;span class="kwrd"&gt;string&lt;/span&gt; PartitaIva //Vat Code
&lt;span class="kwrd"&gt;string&lt;/span&gt; Indirizzo //Address
&lt;span class="kwrd"&gt;string&lt;/span&gt; CAP //Zip code
&lt;span class="kwrd"&gt;string&lt;/span&gt; Citta //City
&lt;span class="kwrd"&gt;string&lt;/span&gt; PV //State or province
&lt;span class="kwrd"&gt;int&lt;/span&gt; IDTipo //Type
&lt;span class="kwrd"&gt;int&lt;/span&gt; IDAnagrafica //Identity&lt;/pre&gt;

&lt;p&gt;To create an Indexer to search through the SearchDescription we can use the following code:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;public AnagraficaAzienda &lt;span class="kwrd"&gt;this&lt;/span&gt;[&lt;span class="kwrd"&gt;string&lt;/span&gt; pDescrizioneRicerca]
{
    get
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt;( Find(item=&amp;gt;item.DescrizioneRicerca==pDescrizioneRicerca);
    }
}&lt;/pre&gt;

&lt;p&gt;to create a method to get all elements that match a regular expression we can use the following code:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;AnagraficaAzienda&amp;gt; FindWithRegEx( &lt;span class="kwrd"&gt;string&lt;/span&gt; pRegEx )
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; (FindAll(items =&amp;gt; Regex.Match(items.RagioneSociale, pRegEx).Success));
}&lt;/pre&gt;

&lt;p&gt;to create a method that returns the data using the Vat Code (PartitaIva) we can use the following code:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; AnagraficaAzienda FindXPartitaIva(&lt;span class="kwrd"&gt;string&lt;/span&gt; pPartitaIva)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt;( Find(item=&amp;gt;item.PartitaIva==pPartitaIva);
}&lt;/pre&gt;

&lt;p&gt;To create a multi dimensional indexer we can use the following code&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; AnagraficaAzienda &lt;span class="kwrd"&gt;this&lt;/span&gt;[&lt;span class="kwrd"&gt;int&lt;/span&gt; pIDZona, &lt;span class="kwrd"&gt;int&lt;/span&gt; pIDAnagrafica]
{
    get
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt;( Find(item=&amp;gt;item.IDZona==pIDZona &amp;amp;&amp;amp; item.IDAnagrafica==pIDAnagrafica);
    }
}&lt;/pre&gt;

&lt;p&gt;as you can see, a Predicate allows us to use any kind of binary expression to match the entity fields with the search criteria we want to use.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:677451c8-0e78-48f4-b0b6-79d9ea72d764" class="wlWriterEditableSmartContent"&gt;Tags: &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Collection/default.aspx" rel="tag"&gt;Collection&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Predicate/default.aspx" rel="tag"&gt;Predicate&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Find/default.aspx" rel="tag"&gt;Find&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/FindAll/default.aspx" rel="tag"&gt;FindAll&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/490.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/13/collection-and-predicates-search-elements-without-cycling.aspx</guid>
            <pubDate>Fri, 13 Aug 2010 15:29:07 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/490.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/13/collection-and-predicates-search-elements-without-cycling.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/490.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to create a Guid.Empty in SQL</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/10/how-to-create-a-guid.empty-in-sql.aspx</link>
            <description>&lt;p&gt;Last friday my colleague Luca was “fighting” with a problem in managing null values and GUIDs. A Guid is a value type so it is not nullable. In my stored procedures when using parameters for filtering, I use the NULL value as the default value to ignore a filter parameter.&lt;/p&gt;  &lt;p&gt;Changing the code of several classes to be able to change a Guid.Empty into a DbNull before passing it to a SELECT command was decisely not the best thing to do, so we searched a way to recreate a Guid.Empty value in SQL.&lt;/p&gt;  &lt;p&gt;We were able to create the small snippet of SQL in the following function:&lt;/p&gt;  &lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;FUNCTION&lt;/span&gt; Guid_Empty()
&lt;span class="kwrd"&gt;RETURNS&lt;/span&gt; UniqueIdentifier
&lt;span class="kwrd"&gt;AS&lt;/span&gt;
&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;
&lt;span class="kwrd"&gt;RETURN&lt;/span&gt; &lt;span class="kwrd"&gt;cast&lt;/span&gt;(&lt;span class="kwrd"&gt;cast&lt;/span&gt;(0 &lt;span class="kwrd"&gt;as&lt;/span&gt; &lt;span class="kwrd"&gt;binary&lt;/span&gt;) &lt;span class="kwrd"&gt;as&lt;/span&gt; uniqueidentifier)
&lt;span class="kwrd"&gt;END&lt;/span&gt;
GO&lt;/pre&gt;

&lt;p&gt;After the creation of the above function and a simple table on my Paperinik Database,  I was able to write the following query:&lt;/p&gt;

&lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [ID]
      ,[Descrizione]
      ,[Prezzo]
      ,[Quantità]
      ,[Umi]
      ,IsNull(AltGuid, dbo.Guid_EMPTY()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Alt
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [paperinik].[dbo].[TbRighe]&lt;/pre&gt;

&lt;p&gt;The query produces the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/HowtocreateaGuid.EmptyinSQL_141CA/guidquery_2.jpg" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="guidquery" border="0" alt="guidquery" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/HowtocreateaGuid.EmptyinSQL_141CA/guidquery_thumb.jpg" width="644" height="104" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I can use it also to build a query like the one below:&lt;/p&gt;

&lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [ID]
      ,[Descrizione]
      ,[Prezzo]
      ,[Quantità]
      ,[Umi]
      ,IsNull(AltGuid, dbo.Guid_EMPTY()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Alt
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [paperinik].[dbo].[TbRighe]
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;
IsNull(AltGuid, dbo.Guid_EMPTY()) = dbo.Guid_EMPTY()&lt;/pre&gt;

&lt;p&gt;That allows me to filter only the Guid Empty rows, or I can use the &amp;lt;&amp;gt; to find only the rows with a non Empty Guid. This way of writing the query, is giving me the possibility to use Guid.Empty in my Code as a SQLParameter value without the need to use a Nullable Guid or to implement complicated control expressions in my C# classes.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:06fc812e-6fbb-411a-9fb5-c5c256bbe9e0" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/SQL" rel="tag"&gt;SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Guid" rel="tag"&gt;Guid&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/484.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/10/how-to-create-a-guid.empty-in-sql.aspx</guid>
            <pubDate>Tue, 10 Aug 2010 20:53:20 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/484.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/10/how-to-create-a-guid.empty-in-sql.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/484.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Access the Deleted Rows of a Datatable</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/09/access-the-deleted-rows-of-a-datatable.aspx</link>
            <description>&lt;p&gt;Today, I’m updating the Code Generator I’ve made in 2006 to build automatically the Data Provider classes for my applications. I’m passing my applications to Framework 4.0 and instead of a simple framework change, I’ve decided to make some cleaning in Old Common Libraries code and add some new features in the Data Classes.&lt;/p&gt;  &lt;p&gt;One of the new features in my data classes, will be some events, raised when data operations complete, RowAdded and RowDeleted events are two of them. In both cases, it would probably be useful if you Handle the Event in your code, to have some informations on the Added Row or Deleted Row, so I decided to pass the whole DataRow as a property of the event argument.&lt;/p&gt;  &lt;p&gt;Pass the Added row as an argument is very simple, I have the object in my method.&lt;/p&gt;  &lt;p&gt;Pass the Deleted row is a little less simple. I’ve made a simple test project to find out how to get it, to be precise, the exact phrase is: &lt;em&gt;How to get a copy of it&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;The sample form is the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/AccesstheDeletedRowsofaDatatable_EFEB/righecancellate_2.jpg" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="righecancellate" border="0" alt="righecancellate" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/AccesstheDeletedRowsofaDatatable_EFEB/righecancellate_thumb.jpg" width="244" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;On the form there are 3 buttons – Carica = Load, Test Aggiunta = Test AddRow, Test cancellazione = Test Deletion. There is also a textbox, set as Multiline with vertical scrollbar.&lt;/p&gt;  &lt;p&gt;The test code is the following:&lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;        DataTable mDt;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_ID = &lt;span class="str"&gt;"ID"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_Description = &lt;span class="str"&gt;"Description"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_Date = &lt;span class="str"&gt;"Date"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_Price = &lt;span class="str"&gt;"Price"&lt;/span&gt;;

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Form1()
        {
            InitializeComponent();
            mDt = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataTable(&lt;span class="str"&gt;"Tbtest"&lt;/span&gt;);
            DataColumn col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_ID, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt;));
            col.AutoIncrement = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            col.AutoIncrementSeed = 1;
            col.AutoIncrementStep = 1;
            mDt.Columns.Add(col);
            col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_Description, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;));
            mDt.Columns.Add(col);
            col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_Date, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DateTime));
            mDt.Columns.Add(col);
            col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_Price, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Decimal));
            mDt.Columns.Add(col);
        }&lt;/pre&gt;

&lt;p&gt;The initialization code, I build a Datatable on the Constructor code of the form.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnCarica_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            mDt.Rows.Clear();

            DataRow row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Quaderno"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 1.5;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Penna"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 2.8;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Gomma"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 0.7;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Matita"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 1.1;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Block notes"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 2.8;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Pennarelli 12 colori"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 6.7;
            mDt.Rows.Add(row);

            mDt.AcceptChanges();

            Mostra();
        }&lt;/pre&gt;

&lt;p&gt;Here I build some rows, put them in the DataTable and call the Mostra method, wich shows the rows in the textbox.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Mostra()
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
            &lt;span class="kwrd"&gt;for&lt;/span&gt;( &lt;span class="kwrd"&gt;int&lt;/span&gt; i=0; i&amp;lt; mDt.Rows.Count;i++)
            {
                MostraRiga(mDt.Rows[i]);
            }
    
        }

        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MostraRiga(DataRow pRow)
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"ID: "&lt;/span&gt; + pRow[FLD_ID].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"Description: "&lt;/span&gt; + pRow[FLD_Description].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"Date: "&lt;/span&gt; + pRow[FLD_Date].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"Price: "&lt;/span&gt; + pRow[FLD_Price].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += Environment.NewLine;
        }&lt;/pre&gt;

&lt;p&gt;This is the Mostra method and the MostraRiga Method, made to show the content of the table rows on the textbox.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnAdd_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {

            DataRow row = mDt.NewRow();
            mDt.Rows.Add(row);
            row[FLD_Description] = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"Nuova riga {0}"&lt;/span&gt;, row[FLD_ID]);
            row[FLD_Date] = DateTime.Now;
            &lt;span class="kwrd"&gt;decimal&lt;/span&gt; pippo = Convert.ToDecimal(row[FLD_ID]);
            row[FLD_Price] = pippo*0.98m;

            mDt.AcceptChanges();

            MostraRiga(row);
        }&lt;/pre&gt;

&lt;p&gt;Here is the AddRow test, that simply builds a row, adds it to the table and then shows it on the textbox.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnDelete_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            DataRow row = mDt.Rows[0];
            &lt;span class="kwrd"&gt;int&lt;/span&gt; id = Convert.ToInt32(row[FLD_ID]);
            row.Delete();
            &lt;span class="kwrd"&gt;string&lt;/span&gt; filter = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0} = {1}"&lt;/span&gt;, FLD_ID, id);
            DataView vi = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataView(mDt, filter,&lt;span class="str"&gt;""&lt;/span&gt;, DataViewRowState.Deleted);
            DataTable tt = vi.ToTable();
            mDt.AcceptChanges();
            MostraRiga(tt.Rows[0]);
        }&lt;/pre&gt;

&lt;p&gt;And finally the most important bit of code, the code that helps us to show the informations of the deleted row.
  &lt;br /&gt;As you can see, the method simply deletes the first row of the DataTable, saving it’s ID. 

  &lt;br /&gt;After the deletion, to be able to get the whole row, I build a dataview that retrieves the row I’ve deleted and then uses the ToTable method of the DataView to put the data in a new Table. Then I give the Row to the MostraRiga (ShowRow) method and I can see its content on my textbox.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;font color="#ff0000"&gt;ToTable &lt;/font&gt;&lt;/strong&gt;passage is very important, because if you try to pass to the function something like:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;MostraRiga(vi[0].Row);&lt;/pre&gt;

&lt;p&gt;Whichis perfectly legal with a non deleted row, you instead receive an Exception, because you cannot access deleted rows data.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:17113bfd-eb5e-4299-8c45-1632c622454a" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DataTable" rel="tag"&gt;DataTable&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DataView" rel="tag"&gt;DataView&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Deleted+Rows" rel="tag"&gt;Deleted Rows&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/482.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/09/access-the-deleted-rows-of-a-datatable.aspx</guid>
            <pubDate>Mon, 09 Aug 2010 15:03:42 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/482.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/09/access-the-deleted-rows-of-a-datatable.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/482.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Use of Rank function to extract a list of rows with the highest date</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/07/07/use-of-rank-function-to-extract-a-list-of-rows.aspx</link>
            <description>&lt;p&gt;Today I had the problem to create a query to get the most recent price from a pricelists table. Every pricelist in the table can contain the same article any number of times with different startup dates. I made some search to find a way to obtain what i needed and I found the RANK function, it was used in a similar scenario. I publish this post as usual to remember how to use this function next time I need it and in the hope to help someone else solving similar problems.&lt;/p&gt;  &lt;p&gt;The table:&lt;/p&gt;  &lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; [dbo].[TbPricelistsRg](
    [IDPriceListRg] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [IDPriceList] [nvarchar](10) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [IDArticle] [nvarchar](32) &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Price] [&lt;span class="kwrd"&gt;decimal&lt;/span&gt;](18, 5) &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [StartDate] [&lt;span class="kwrd"&gt;date&lt;/span&gt;] &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
 &lt;span class="kwrd"&gt;CONSTRAINT&lt;/span&gt; [PK_TbPriceListsRg] &lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt; &lt;span class="kwrd"&gt;KEY&lt;/span&gt; &lt;span class="kwrd"&gt;CLUSTERED&lt;/span&gt; 
(
    [IDPriceListRg] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;
)&lt;span class="kwrd"&gt;WITH&lt;/span&gt; (PAD_INDEX  = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, STATISTICS_NORECOMPUTE  = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, IGNORE_DUP_KEY = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, ALLOW_ROW_LOCKS  &lt;br /&gt;     = &lt;span class="kwrd"&gt;ON&lt;/span&gt;, ALLOW_PAGE_LOCKS  = &lt;span class="kwrd"&gt;ON&lt;/span&gt;) &lt;span class="kwrd"&gt;ON&lt;/span&gt; [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;]
) &lt;span class="kwrd"&gt;ON&lt;/span&gt; [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;

&lt;p&gt;Every row is linked to a PriceList through the IDPriceLIst field, we don’t need to use it for the example so it is omitted.&lt;/p&gt;

&lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'ABC'&lt;/span&gt;
           ,10
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'OCQ'&lt;/span&gt;
           ,14
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'FYS'&lt;/span&gt;
           ,21
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'MUI'&lt;/span&gt;
           ,13
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'SIO'&lt;/span&gt;
           ,42
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'GOU'&lt;/span&gt;
           ,18
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; [dbo].[TbPricelistsRg]
           ([IDPriceList]
           ,[IDArticle]
           ,[Price]
           ,[StartDate])
     &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
           (&lt;span class="str"&gt;'CLD'&lt;/span&gt;
           ,&lt;span class="str"&gt;'HOU'&lt;/span&gt;
           ,20
           ,&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;date&lt;/span&gt;, &lt;span class="str"&gt;'20080105'&lt;/span&gt;, 112))
&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;The previous script inserts some articles, we can repeat it changing the PriceLIst, the Dates and prices to be able to show how the query meets our needs.&lt;/p&gt;

&lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [IDPriceListRg]
      ,[IDPriceList]
      ,[IDArticle]
      ,[Price]
      ,[StartDate]
      ,RANK() &lt;span class="kwrd"&gt;OVER&lt;/span&gt; (PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; IDPriceList, IDArticle &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; StartDate &lt;span class="kwrd"&gt;DESC&lt;/span&gt;) DATERANK
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [paperinik].[dbo].[TbPricelistsRg]&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;font color="#0080ff"&gt;RANK&lt;/font&gt;&lt;/strong&gt; function, allows us to indicate one or more grouping fields on which calculate ranking, this is done using the &lt;strong&gt;&lt;font color="#0080ff"&gt;PARTITION BY&lt;/font&gt;&lt;/strong&gt; keywords, in our query we indicate the two fields on which ranking has to break. The &lt;font color="#0080ff"&gt;&lt;strong&gt;ORDER BY&lt;/strong&gt;&lt;/font&gt;  keyword, instead indicates on which field we have to measure ranking. while the &lt;font color="#0080ff"&gt;&lt;strong&gt;DESC&lt;/strong&gt;&lt;/font&gt; keywords tells that we want to start from the most recent date..&lt;/p&gt;

&lt;p&gt;This is the result of our query.&lt;/p&gt;

&lt;table style="width: 296pt; border-collapse: collapse" border="0" cellspacing="0" cellpadding="0" width="395"&gt;&lt;colgroup&gt;&lt;col style="width: 48pt" width="64" /&gt;&lt;col style="width: 56pt; mso-width-source: userset; mso-width-alt: 2742" width="75" /&gt;&lt;col style="width: 48pt" width="64" /&gt;&lt;/colgroup&gt;&lt;tbody&gt;
    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="width: 48pt; height: 15pt" height="20" width="64"&gt;IDListinoRg&lt;/td&gt;

      &lt;td style="width: 48pt" width="64"&gt;IDListino&lt;/td&gt;

      &lt;td style="width: 48pt" width="64"&gt;IDArticolo&lt;/td&gt;

      &lt;td style="width: 48pt" width="64"&gt;Prezzo&lt;/td&gt;

      &lt;td style="width: 56pt" width="75"&gt;ValidoDal&lt;/td&gt;

      &lt;td style="width: 48pt" width="64"&gt;DATERANK&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;107&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;24/10/2010&lt;/td&gt;

      &lt;td align="right"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;86&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;15/05/2010&lt;/td&gt;

      &lt;td align="right"&gt;2&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;65&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/01/2010&lt;/td&gt;

      &lt;td align="right"&gt;3&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;44&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/09/2009&lt;/td&gt;

      &lt;td align="right"&gt;4&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;23&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;16/04/2009&lt;/td&gt;

      &lt;td align="right"&gt;5&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;1&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;05/01/2008&lt;/td&gt;

      &lt;td align="right"&gt;6&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;2&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;ABC&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;05/01/2008&lt;/td&gt;

      &lt;td align="right"&gt;6&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;109&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;FYS&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.100.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;24/10/2010&lt;/td&gt;

      &lt;td align="right"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;88&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;FYS&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.100.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;15/05/2010&lt;/td&gt;

      &lt;td align="right"&gt;2&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;67&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;FYS&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.100.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/01/2010&lt;/td&gt;

      &lt;td align="right"&gt;3&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;46&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;FYS&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.100.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/09/2009&lt;/td&gt;

      &lt;td align="right"&gt;4&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;25&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;FYS&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.100.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;16/04/2009&lt;/td&gt;

      &lt;td align="right"&gt;5&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;4&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;FYS&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.100.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;05/01/2008&lt;/td&gt;

      &lt;td align="right"&gt;6&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;112&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;GOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.800.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;24/10/2010&lt;/td&gt;

      &lt;td align="right"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;91&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;GOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.800.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;15/05/2010&lt;/td&gt;

      &lt;td align="right"&gt;2&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;70&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;GOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.800.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/01/2010&lt;/td&gt;

      &lt;td align="right"&gt;3&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;49&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;GOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.800.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/09/2009&lt;/td&gt;

      &lt;td align="right"&gt;4&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;28&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;GOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.800.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;16/04/2009&lt;/td&gt;

      &lt;td align="right"&gt;5&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;7&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;GOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;1.800.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;05/01/2008&lt;/td&gt;

      &lt;td align="right"&gt;6&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;113&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;HOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;24/10/2010&lt;/td&gt;

      &lt;td align="right"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;92&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;HOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;15/05/2010&lt;/td&gt;

      &lt;td align="right"&gt;2&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;71&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;HOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/01/2010&lt;/td&gt;

      &lt;td align="right"&gt;3&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;50&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;HOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;08/09/2009&lt;/td&gt;

      &lt;td align="right"&gt;4&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;29&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;HOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;16/04/2009&lt;/td&gt;

      &lt;td align="right"&gt;5&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="height: 15pt" height="20"&gt;
      &lt;td style="height: 15pt" height="20" align="right"&gt;8&lt;/td&gt;

      &lt;td&gt;CLD&lt;/td&gt;

      &lt;td&gt;HOU&lt;/td&gt;

      &lt;td class="xl63" align="right"&gt;2.000.000&lt;/td&gt;

      &lt;td class="xl64" align="right"&gt;05/01/2008&lt;/td&gt;

      &lt;td align="right"&gt;6&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;So to obtain the most recent prices, we need just to add a filter on DATERANK = 1, and to obtain the less recent price we just need to delete the DESC keyword and filter on rank 1.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:27b8a83b-f846-404d-ae0f-c3a2d70793b7" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/SQL" rel="tag"&gt;SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/RANK" rel="tag"&gt;RANK&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DATE" rel="tag"&gt;DATE&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/453.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/07/07/use-of-rank-function-to-extract-a-list-of-rows.aspx</guid>
            <pubDate>Wed, 07 Jul 2010 21:45:13 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/453.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/07/07/use-of-rank-function-to-extract-a-list-of-rows.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/453.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
