﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Create an Expression Column</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Creates a DataColumn object and sets the DataColumn.Expression property to calculate the order total.</Description>
      <Shortcut>adoAddExpression</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>System.Data.dll</Assembly>
        </Reference>
        <Reference>
          <Assembly>System.Xml.dll</Assembly>
        </Reference>
      </References>
      <Imports>
        <Import>
          <Namespace>System.Data</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>ColumnName</ID>
          <Type>String</Type>
          <ToolTip>Replace with the column name.</ToolTip>
          <Default>OrderTotal</Default>
        </Literal>
        <Literal>
          <ID>Expression</ID>
          <Type>String</Type>
          <ToolTip>Replace with an expression that evaluates to the column type.</ToolTip>
          <Default>UnitPrice * Quantity</Default>
        </Literal>
        <Object>
          <ID>DataSet</ID>
          <Type>System.Data.DataSet</Type>
          <ToolTip>Replace with a DataSet object.</ToolTip>
          <Default>ds</Default>
        </Object>
        <Object>
          <ID>ExpressionColumn</ID>
          <Type>System.Data.DataColumn</Type>
          <ToolTip>The new expression column to add to the DataTable</ToolTip>
          <Default>orderTotalColumn</Default>
        </Object>
        <Object>
          <ID>DataTable</ID>
          <Type>System.Data.DataTable</Type>
          <ToolTip>The DataTable to add the expression column to</ToolTip>
          <Default>Order_Details</Default>
        </Object>
        <Object>
          <ID>ColumnDataType</ID>
          <ToolTip>Replace with datatype.</ToolTip>
          <Default>Double</Default>
        </Object>
      </Declarations>
      <Code Language="VB" Kind="method decl"><![CDATA[Dim $ExpressionColumn$ As New DataColumn()
$ExpressionColumn$.ColumnName = "$ColumnName$"
$ExpressionColumn$.DataType = GetType($ColumnDataType$)
$ExpressionColumn$.Expression = "$Expression$"
$DataSet$.$DataTable$.Columns.Add($ExpressionColumn$)
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>