using System;
using System.Xml;
using System.Xml.Serialization;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Diagnostics;
using System.Runtime;
using System.Runtime.Serialization;
using Tdo;
using Tdo.Common;
using Tdo.Common.Entities;
using Tdo.Common.Entities.Tables;
using Tdo.Common.Entities.Views;
using Tdo.Common.Helper;
using Tdo.Common.TdoSqlExpressionDom;
using Tdo.Common.TdoTypes;
namespace Tdo.Common.Programmability{
/// <summary>
/// TdoTableFunctionBase class. It's the default class of all Table-valued Functions.
/// </summary>
[Serializable]
[CLSCompliant(true)]
[Browsable(false)]
public class TdoTableFunctionBase : TdoViewBase, ITdoTableFunction
{
#region Fields
/// <summary>
/// Table-valued SqlParamaters Array
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields"), NonSerialized()]
protected internal SqlParameter[] pTableParameters;
#endregion Fields
#region Constructors
/// <summary>
/// TdoTableFunctionBase Default Constructor
/// </summary>
public TdoTableFunctionBase()
{
this.pTableParameters = new SqlParameter[0];
}
#endregion Constructors
#region Properties
/// <summary>
/// References Table-valued SqlParamaters Array
/// </summary>
SqlParameter[] ITdoTableFunction.TableParameters
{
get
{
return this.pTableParameters;
}
}
#endregion Properties
#region Methods
/// <summary>
/// Quickly assigns table parameter values with supplied Sql Values.
/// </summary>
/// <param name="tableParameters">INullable parameters array to assign to Table Parameters</param>
/// <remarks>To assign Null values use SqlXxxxx.Null like SqlString.Null and SqlInt32.Null</remarks>
/// <exception cref="System.ArgumentException">thrown when tableParameters array length does not match TableParameters array length</exception>
void ITdoTableFunction.AssignTableParameters(params INullable[] tableParameters)
{
if (this.pTableParameters.Length != tableParameters.Length)
throw new ArgumentException("tableParameters array length does not match TableParameters array length.");
for (int i=0;i<this.pTableParameters.Length;i++)
{
this.pTableParameters[i].Value = tableParameters[i];
}
}
/// <summary>
/// Returns full entity name.
/// </summary>
/// <returns>string with full entity name.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider")]
protected internal override string FullSelectEntityName()
{
string parameterNames = String.Empty;
foreach (SqlParameter parameter in this.pTableParameters)
{
((TdoParameterCollection)this.pTdoParameterCollection).ParameterCollection.Add(((ICloneable)parameter).Clone());
parameterNames += parameter.ParameterName + ",";
}
parameterNames = parameterNames.TrimEnd(',');
return String.Format("{0}({1}) {2}", this.FullEntityName, parameterNames, this.EntityName);
}
#endregion Methods
}
}
|