Gets the XML Qualified name for
TdIntervalDay XML type mapping.
This example shows how to use the
TdIntervalDay with
Xml.Serialization.XmlSerializer class.
Xml.Serialization.XmlElementAttribute is used to indicate that the Teradata Database column can be
Null.
public class Order
{
public TdTimestamp Date;
public TdIntervalDay ExpirationPeriod;
public TdTimestamp ExpirationDate;
public Int32 ProductId;
public Int32 Quantity;
public Int32? BackOrderQuantity;
[XmlElementAttribute(IsNullable = true)]
public TdDecimal BackOrderPrice;
}
internal class OrderWriter
{
public static void Write()
{
// Setup the order
Order x = new Order();
x.Date = new TdTimestamp(DateTime.Today);
// 5 days
x.ExpirationPeriod = new TdIntervalDay(5);
x.ExpirationDate = x.Date + x.ExpirationPeriod;
x.ProductId = 100;
x.Quantity = 2000;
x.BackOrderQuantity = null;
x.BackOrderPrice = TdDecimal.Null;
// Write out today's orders to the file.
//
// Open the file.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter writer = XmlWriter.Create(@"C:\Temp\TodayOrders.XML", settings);
writer.WriteStartElement("TodayOrders");
// Write out the schema.
XmlSchemas schemas = new XmlSchemas();
XmlSchemaExporter schExporter = new XmlSchemaExporter(schemas);
schExporter.ExportTypeMapping(new XmlReflectionImporter().ImportTypeMapping(typeof(Order)));
schemas[0].Write(writer);
// Write out the orders.
XmlSerializer xml = new XmlSerializer(typeof(Order));
xml.Serialize(writer, x);
// Close the document.
writer.WriteEndDocument();
writer.Close();
}
}
/* Output is:
<TodayOrders>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Order" nillable="true" type="Order" />
<xs:complexType name="Order">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Date" type="xs:dateTime" />
<xs:element minOccurs="1" maxOccurs="1" name="ExpirationPeriod" type="xs:duration" />
<xs:element minOccurs="1" maxOccurs="1" name="ExpirationDate" type="xs:dateTime" />
<xs:element minOccurs="1" maxOccurs="1" name="ProductId" type="xs:int" />
<xs:element minOccurs="1" maxOccurs="1" name="Quantity" type="xs:int" />
<xs:element minOccurs="1" maxOccurs="1" name="BackOrderQuantity" nillable="true" type="xs:int" />
<xs:element minOccurs="1" maxOccurs="1" name="BackOrderPrice" nillable="true" type="xs:decimal" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Date>2008-02-01T00:00:00-08:00</Date>
<ExpirationPeriod>P5D</ExpirationPeriod>
<ExpirationDate>2008-02-06T04:00:00-08:00</ExpirationDate>
<ProductId>100</ProductId>
<Quantity>2000</Quantity>
<BackOrderQuantity xsi:nil="true" />
<BackOrderPrice xsi:nil="true" />
</Order>
</TodayOrders>
*/
Target Platforms: Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2