TdoEntityBase.cs :  » Database » TDO » Tdo » Common » Entities » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Database » TDO 
TDO » Tdo » Common » Entities » TdoEntityBase.cs
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections;
using System.Collections.Specialized;
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.Programmability;
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.Entities{
    /// <summary>
    /// Base class for all Tables and Views
    /// </summary>
    [Serializable()]
    [CLSCompliant(true)]
    [System.ComponentModel.DesignTimeVisible(false)]
    [Browsable(true)]
    [ToolboxItem(false)]
    [DefaultProperty("EntityName")]
    [System.ComponentModel.DataObject]
    public class TdoEntityBase : IComponent, ITdoEntity
    {
        #region Fields
        [NonSerialized()]
        private ISite iSite;
        /// <summary>
        /// Get or Set SqlCommand time out (default is 60 seconds)
        /// </summary>
        [XmlIgnore]
        protected int pCommandTimeOut;
        /// <summary>
        /// Reference to TdoHelper.
        /// </summary>
        [XmlIgnore]
        [NonSerialized()]
        private ITdoHelper pTdoHelper;
        /// <summary>
        /// Returns Collection of Table Columns
        /// </summary>
        //[XmlIgnore]
        //[NonSerialized()]
        protected ITdoColumn[] pTdoColumns;
        /// <summary>
        /// Physical Entity Schema Name
        /// </summary>
        [XmlIgnore]
        protected string pSchemaName;
        /// <summary>
        /// Physical Entity Name
        /// </summary>
        [XmlIgnore]
        protected string pEntityName;
        /// <summary>
        /// Reference to the SQL Connection of TDOHelper class
        /// </summary>
        [NonSerialized]
        [XmlIgnore]
        protected SqlConnection pSqlConnection;
        /// <summary>
        /// Always Keeps the last number of records involved in insert,update,delete and stored procedures operations.
        /// </summary>
        [XmlIgnore]
        protected int pLastaffectedrecords;
        /// <summary>
        /// Parameters collection  for parametric queries
        /// </summary>
        [NonSerialized]
        [XmlIgnore]
        internal volatile TdoParameterCollection pTdoParameterCollection;
        #endregion Fields
        #region Constructors
        /// <summary>
        ///  TdoEntityBase Constructor
        /// </summary>
        public TdoEntityBase()
        {
            this.pTdoParameterCollection = new TdoParameterCollection();
            if (this.TdoHelper != null)
                this.pCommandTimeOut = this.TdoHelper.CommandTimeOut;
            else
                this.pCommandTimeOut = 60;
            this.pSchemaName = String.Empty;
            this.pEntityName = String.Empty;
        }
        #endregion Constructors
        #region Properties
        /// <summary>
        /// Get or Set SqlCommand time out (default is 60 seconds)
        /// </summary>
        [XmlIgnore]
        [Browsable(false)]
        public virtual int CommandTimeOut
        {
            get
            {
                return this.pCommandTimeOut;
            }
            set
            {
                this.pCommandTimeOut = value;
            }
        }
        /// <summary>
        /// Get or Set TdoHelper reference to share common resources
        /// </summary>
        /// <remarks>this property must be assigned before you can use methods and/or entity properties.</remarks>
        [XmlIgnore]
        [Browsable(false)]
        public virtual ITdoHelper TdoHelper
        {
            get
            {
                return this.pTdoHelper;
            }
            set
            {
                this.pTdoHelper = value; this.pSqlConnection = value.Connection;
            }
        }
        /// <summary>
        /// Returns or sets the parameters collection to use in parametric queries
        /// </summary>
        [XmlIgnore]
        [Browsable(false)]
        protected TdoParameterCollection TdoParameterCollection
        {
            get
            {
                return this.pTdoParameterCollection;
            }
            set
            {
                this.pTdoParameterCollection = value;
            }
        }
        /// <summary>
        /// Get or Set Schema Name
        /// </summary>
        [XmlAttribute()]
        [Browsable(false)]
        public string SchemaName
        {
            get
            {
                return this.pSchemaName;
            }
            set
            {
                this.pSchemaName = value;
            }

        }
        /// <summary>
        /// Get or Set entity name
        /// </summary>
        [XmlAttribute()]
        [Browsable(false)]
        public string EntityName
        {
            get
            {
                return this.pEntityName;
            }
            set
            {
                this.pEntityName = value;
            }

        }
        /// <summary>
        /// Get Full entity name ([schema].[entity])
        /// </summary>
        [Browsable(false)]
        public string FullEntityName
        {
            get
            {
                return String.Concat(this.pSchemaName, ".", this.pEntityName);
            }
        }

        /// <summary>
        /// Always Keeps the last number of records involved in insert,update,delete and stored procedures operations.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider"), XmlIgnore]
        [Browsable(false)]
        public int LastAffectedRecords
        {
            get
            {
                if (this.pLastaffectedrecords != -1) return this.pLastaffectedrecords;
                SqlCommand comm = new SqlCommand("select @@rowcount", this.pSqlConnection, this.TdoHelper.Transaction);
                this.pLastaffectedrecords = Convert.ToInt32(comm.ExecuteScalar());
                return this.pLastaffectedrecords;
            }
        }
        /// <summary>
        /// Get Columns Table Collection
        /// </summary>
        [XmlIgnore()]
        [Browsable(false)]
        public virtual ITdoColumn[] TdoColumns
        {
            get
            {
                return this.pTdoColumns;
            }
        }
        #endregion Properties
        #region Methods
        internal string ColumnNamesOrValues(ITdoColumn[] columns)
        {
            string fields = String.Empty;
            if (columns.Length == 0)
                return String.Concat(this.EntityName, ".*").TrimStart('.');
            foreach (ITdoColumn column in columns)
            {
                if (column.IsConstant)
                {
                    fields += column.ObjectValue.ToString() + (!String.IsNullOrEmpty(column.Caption) ? " as [" + column.Caption + "] " : String.Empty) + ",";
                }
                else
                {
                    fields += column.TdoEntity.EntityName + (!String.IsNullOrEmpty(column.TdoEntity.EntityName) ? "." : String.Empty) + (String.IsNullOrEmpty(column.Caption) ? column.ColumnName : column.ColumnName + " as [" + column.Caption + "] ") + ",";
                }
            }
            fields = fields.Trim(',');
            return fields;
        }
        internal static string FieldsJoinList(ITdoColumn[] columns)
        {
            string fields = String.Empty;
            foreach (ITdoColumn column in columns)
            {
                if (column.IsConstant)
                {
                    fields += column.ObjectValue.ToString() + (!String.IsNullOrEmpty(column.Caption) ? " as [" + column.Caption + "] " : String.Empty) + ",";
                }
                else
                {
                    fields += column.TdoEntity.EntityName + (!String.IsNullOrEmpty(column.TdoEntity.EntityName) ? "." : String.Empty) + (String.IsNullOrEmpty(column.Caption) ? column.ColumnName : column.ColumnName + " as [" + column.Caption + "] ") + ",";
                }
            }
            fields = fields.Trim(',');
            if (String.IsNullOrEmpty(fields)) fields = "*";
            return fields;
        }
        /// <summary>
        /// Creates a DataTable instance with the table records  searched before. 
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="dataAdapter">DataAdapter to modify DataTable object</param> 
        /// <param name="transaction"> Current Transaction </param> 
        /// <param name="generateCommands">Boolean that indicates if is to generate Commands for Insert, Update e Delete of DataAdapter</param>
        /// <param name="fields">fields list (ITdoType or string) to select</param> 
        /// <returns>DataTable with the table records </returns>
        private DataTable SelectDataTable(string clauses, out SqlDataAdapter dataAdapter, SqlTransaction transaction, bool generateCommands, params ITdoColumn[] fields)
        {
            string sfields = this.ColumnNamesOrValues(fields);
            string sqlselect = "SELECT " + sfields + " FROM " + this.FullSelectEntityName() + clauses;
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            this.TdoHelper.PrepareAutomaticConnection();
            sqlCommand.CommandTimeout = this.pCommandTimeOut;
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            sqlCommand.Parameters.AddRange(this.pTdoParameterCollection.ParameterCollection.ToArray());
            SqlDataAdapter da = new SqlDataAdapter(sqlCommand);
            da.FillError += new FillErrorEventHandler(this.internalFillErrorEventHandler);
            da.RowUpdated += new SqlRowUpdatedEventHandler(this.internalRowUpdatedEventHandler);
            da.RowUpdating += new SqlRowUpdatingEventHandler(this.internalRowUpdatingEventHandler);
            DataTable dt = new DataTable(this.EntityName);
            dt.Locale = System.Globalization.CultureInfo.InvariantCulture;
            if (generateCommands)
            {
                SqlCommandBuilder cb = new SqlCommandBuilder(da);
                cb.QuotePrefix = "[";
                cb.QuoteSuffix = "]";
                da.InsertCommand = null;
                da.UpdateCommand = null;
                da.DeleteCommand = null;
                try
                {
                    da.InsertCommand = cb.GetInsertCommand();
                    da.InsertCommand.Transaction = transaction;
                    da.InsertCommand.CommandTimeout = this.pCommandTimeOut;
                }
                catch
                {
                    da.InsertCommand = null;
                }
                try
                {
                    da.UpdateCommand = cb.GetUpdateCommand();
                    da.UpdateCommand.Transaction = transaction;
                    da.UpdateCommand.CommandTimeout = this.pCommandTimeOut;
                }
                catch
                {
                    da.UpdateCommand = null;
                }
                try
                {
                    da.DeleteCommand = cb.GetDeleteCommand();
                    da.DeleteCommand.Transaction = transaction;
                    da.DeleteCommand.CommandTimeout = this.pCommandTimeOut;

                }
                catch
                {
                    da.DeleteCommand = null;
                }
            }
            dt.BeginLoadData();
            da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
            da.Fill(dt);
            dt.EndLoadData();
            dataAdapter = da;
            this.TdoParameterCollection.Reset();
            this.TdoHelper.UnPrepareAutomaticConnection();
            return dt;
        }
        /// <summary>
        /// Create a DataRow with class properties actualValue, for only fields in destinationTable
        /// </summary>
        /// <param name="destinationTable">It is the entity from which derive row schema</param>
        /// <returns>Return a DataRow instance with class properties actualValue.</returns>
        public virtual DataRow FillDataRow(DataTable destinationTable)
        {
            DataRow dr = destinationTable.NewRow();
            foreach (ITdoColumn column in this.pTdoColumns)
            {
                if (destinationTable.Columns.Contains(column.ColumnName))
                {
                    object ov = column.ObjectValue;
                    Type t = ov.GetType();
                    object v = DBNull.Value;
                    if (!column.IsNull)
                    {
                        if (t.Namespace == "System.Data.SqlTypes")
                            v = ov.GetType().InvokeMember("Value", System.Reflection.BindingFlags.GetProperty, null, ov, null);
                        else if (ov != DBNull.Value)
                            v = ov;
                    }
                    dr[column.ColumnName] = v;
                }
            }
            return dr;
        }
        /// <summary>
        /// Verify if exists at least one record in Entity [Employees] 
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <returns>true if exists, else false.</returns>
        public virtual bool Exists(string clauses)
        {
            try
            {
                this.TdoHelper.PrepareAutomaticConnection();
                using (SqlDataReader dr = this.SelectDataReader(clauses, CommandBehavior.SingleRow))
                {
                    if (!dr.Read())
                    {
                        dr.Close();
                        return false;
                    }
                    else
                    {
                        dr.Close();
                        return true;
                    }
                }
            }
            finally
            {
                this.TdoHelper.UnPrepareAutomaticConnection();
            }
        }
        /// <summary>
        /// Select one or more record(s) from Entity  using search criteria.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>SqlDataReader for reading results.</returns>
        public virtual SqlDataReader SelectDataReader(string clauses, params ITdoColumn[] fields)
        {
            return this.SelectDataReader(clauses, CommandBehavior.Default, fields);
        }
        /// <summary>
        /// Select one or more record(s) from Entity  using search criteria.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <returns>SqlDataReader for reading results.</returns>
        public virtual SqlDataReader SelectDataReader(string clauses, CommandBehavior commandBehavior, params ITdoColumn[] fields)
        {
            return this.SelectDataReader(clauses, this.ColumnNamesOrValues(fields), commandBehavior);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="commandBehavior">One of the System.Data.CommandBehavior values, indicating options for statement execution and data retrieval.</param>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        private IAsyncResult BeginSelectDataReader(AsyncCallback callBack, object stateObject, CommandBehavior commandBehavior, string clauses, string fields)
        {
            //Prepare select statement
            string sqlselect = "";
            sqlselect = "select " + fields + " from " + this.FullSelectEntityName() + " ";
            //Adding where clause
            sqlselect += " " + clauses;
            //prepare query
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            this.TdoHelper.PrepareAutomaticConnection();
            sqlCommand.CommandTimeout = this.pCommandTimeOut;
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            sqlCommand.Parameters.AddRange(this.TdoParameterCollection.ParameterCollection.ToArray());
            //execute query
            this.TdoParameterCollection.Reset();

            AsyncCallback tdoAsyncCallback = new AsyncCallback(this.internalAsyncCommandTerminated);
            TdoStateObject tdoStateObject = new TdoStateObject(callBack, stateObject, "SelectDataReader");

            ((ITdoHelper)this.TdoHelper).SqlCommandAsyncStore.Add(tdoStateObject.AsyncCommandUniqueIdentifier, sqlCommand);

            IAsyncResult asyncResult = sqlCommand.BeginExecuteReader(tdoAsyncCallback, tdoStateObject, commandBehavior);
            return asyncResult;
        }

        internal void internalAsyncCommandTerminated(IAsyncResult asyncResult)
        {
            TdoStateObject tdoStateObject = asyncResult.AsyncState as TdoStateObject;
            if (tdoStateObject == null)
                throw new InvalidProgramException("Tdo Internal Error in internalAsyncCommandTerminated. Cannot retrieve TdoStateObject. Please report this error at Tdo Staff.");
            this.TdoHelper.UnPrepareAutomaticTransaction();
            this.TdoHelper.UnPrepareAutomaticConnection();
            if (tdoStateObject.callBack != null)
            {
                TdoAsyncResult tdoAsyncResult = new TdoAsyncResult();
                tdoAsyncResult.pAsyncState = tdoStateObject.StateObject;
                tdoAsyncResult.pAsyncWaitHandle = asyncResult.AsyncWaitHandle;
                tdoAsyncResult.pCompletedSynchronously = asyncResult.CompletedSynchronously;
                tdoAsyncResult.pIsCompleted = asyncResult.IsCompleted;
                tdoStateObject.callBack(tdoAsyncResult);
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(AsyncCallback callBack, object stateObject, CommandBehavior commandBehavior, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(callBack, stateObject, commandBehavior, TdoSqlExpression.Empty, fields);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(CommandBehavior commandBehavior, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(null, null, commandBehavior, TdoSqlExpression.Empty, fields);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(null, null, TdoSqlExpression.Empty, fields);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(AsyncCallback callBack, object stateObject, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(callBack, stateObject, TdoSqlExpression.Empty, fields);
        }

        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(CommandBehavior commandBehavior, string clauses, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(null, null, commandBehavior, clauses, fields);
        }

        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(AsyncCallback callBack, object stateObject, CommandBehavior commandBehavior, string clauses, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(callBack, stateObject, commandBehavior, clauses, this.ColumnNamesOrValues(fields));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(string clauses, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(null, null, clauses, fields);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Select statement using search criteria, and retrieves one or more result sets from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Data.SqlClient.SqlDataReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectDataReader(AsyncCallback callBack, object stateObject, string clauses, params ITdoColumn[] fields)
        {
            return this.BeginSelectDataReader(callBack, stateObject, CommandBehavior.Default, clauses, fields);
        }

        /// <summary>
        /// Finishes asynchronous execution of a Select statement, returning the requested System.Data.SqlClient.SqlDataReader.
        /// </summary>
        /// <param name="asyncResult">The System.IAsyncResult returned by the call to BeginSelectDataReader.</param>
        /// <returns>A System.Data.SqlClient.SqlDataReader object that can be used to retrieve the requested rows.</returns>
        public SqlDataReader EndSelectDataReader(IAsyncResult asyncResult)
        {
            return ((SqlDataReader)this.internalEndAsyncCommand(asyncResult));
        }

        /// <summary>
        /// Finishes asynchronous execution of a Select FOR XML statement, returning the requested System.Xml.XmlReader
        /// </summary>
        /// <param name="asyncResult">The System.IAsyncResult returned by the call to BeginSelectXmlReader.</param>
        /// <returns>A System.Xml.XmlReader object that can be used to retrieve the requested rows.</returns>
        public XmlReader EndSelectXmlReader(IAsyncResult asyncResult)
        {
            return ((XmlReader)this.internalEndAsyncCommand(asyncResult));
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider")]
        internal object internalEndAsyncCommand(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
                throw new ArgumentNullException("asyncResult", "value cannot be null");
            TdoStateObject tdoStateObject = asyncResult.AsyncState as TdoStateObject;
            if (tdoStateObject == null)
                throw new InvalidCastException("asyncResult is not the same returned object from Begin method.");
            string methodName = tdoStateObject.MethodName;
            Guid key = tdoStateObject.AsyncCommandUniqueIdentifier;
            if (!((ITdoHelper)this.TdoHelper).SqlCommandAsyncStore.Contains(key))
                throw new InvalidOperationException(string.Format("Begin{0} must be invoked first of End{0} or End{0} was invoked more then once.", methodName));
            SqlCommand comm = ((ITdoHelper)this.TdoHelper).SqlCommandAsyncStore[key] as SqlCommand;
            if (comm == null)
                throw new InvalidCastException(String.Format("asyncResult is not the same returned object from Begin{0}.", methodName));
            try
            {
                switch (methodName)
                {
                    case "SelectDataReader":
                        SqlDataReader sqlDataReader = comm.EndExecuteReader(asyncResult);
                        return sqlDataReader;
                    case "SelectXmlReader":
                        XmlReader xmlReader = comm.EndExecuteXmlReader(asyncResult);
                        return xmlReader;
                    case "Insert":
                        SqlDataReader sqlInsertDataReader = comm.EndExecuteReader(asyncResult);
                        return sqlInsertDataReader;
                    case "Update":
                    case "Delete":
                        int affectedRecords = comm.EndExecuteNonQuery(asyncResult);
                        this.TdoHelper.UnPrepareAutomaticTransaction();
                        this.TdoHelper.UnPrepareAutomaticConnection();
                        return affectedRecords;
                    default:
                        throw new ArgumentException(String.Format("Invalid method name ({0})", methodName));
                }
            }
            finally
            {
                ((ITdoHelper)this.TdoHelper).SqlCommandAsyncStore.Remove(key);
            }
        }

        /// <summary>
        /// Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra columns or rows are ignored.
        /// </summary>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>The first column of the first row in the resultset.</returns>
        public virtual object SelectScalar(params ITdoColumn[] fields)
        {
            //Ritorna tutti i record - select *
            return this.SelectScalar(String.Empty, fields);
        }

        /// <summary>
        /// Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra columns or rows are ignored.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>The first column of the first row in the resultset.</returns>
        public virtual object SelectScalar(string clauses, params ITdoColumn[] fields)
        {
            //Prepare select statement
            string sfields = this.ColumnNamesOrValues(fields);
            string sqlselect = "";
            sqlselect = "select " + sfields + " from " + this.FullSelectEntityName() + " ";
            //Adding where clause
            sqlselect += " " + clauses;
            //prepare query
            this.TdoHelper.PrepareAutomaticConnection();
            this.TdoHelper.PrepareAutomaticTransaction();
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            sqlCommand.CommandTimeout = this.pCommandTimeOut;
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            sqlCommand.Parameters.AddRange(this.TdoParameterCollection.ParameterCollection.ToArray());
            //execute query
            this.TdoParameterCollection.Reset();
            return sqlCommand.ExecuteScalar();
        }

        /// <summary>
        /// Select one or more record(s) from current Entity using search criteria.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select.</param>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <returns>SqlDataReader for reading results.</returns>
        private SqlDataReader SelectDataReader(string clauses, string fields, CommandBehavior commandBehavior)
        {
            //Prepare select statement
            string sqlselect = "";
            sqlselect = "select " + fields + " from " + this.FullSelectEntityName() + " ";
            //Adding where clause
            sqlselect += " " + clauses;
            //prepare query
            this.TdoHelper.PrepareAutomaticConnection();
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            sqlCommand.CommandTimeout = this.pCommandTimeOut;
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            sqlCommand.Parameters.AddRange(this.TdoParameterCollection.ParameterCollection.ToArray());
            //execute query
            this.TdoParameterCollection.Reset();
            return sqlCommand.ExecuteReader(commandBehavior);
        }
        /// <summary>
        /// Select one or more record(s) from current Entity using search criteria.
        /// </summary>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>SqlDataReader for reading results.</returns>
        public virtual SqlDataReader SelectDataReader(params ITdoColumn[] fields)
        {
            //Ritorna tutti i record - select *
            return this.SelectDataReader(TdoSqlExpression.Empty, CommandBehavior.Default, fields);
        }
        /// <summary>
        /// Select one or more record(s) from current Entity using search criteria with specified CommandBehaviour.
        /// </summary>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <param name="commandBehavior">SqlDateReader CommandBehavior</param>
        /// <returns>SqlDataReader for reading results.</returns>
        public virtual SqlDataReader SelectDataReader(CommandBehavior commandBehavior, params ITdoColumn[] fields)
        {
            //Ritorna tutti i record - select *
            return this.SelectDataReader(TdoSqlExpression.Empty, commandBehavior, fields);
        }
        /// <summary>
        /// Return an instance of DataTable class using search criteria.
        /// </summary>
        /// <param name="dataAdapter">SqlDataAdapter for dataset operations.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>DataTable</returns>
        public virtual DataTable SelectDataTable(out SqlDataAdapter dataAdapter, params ITdoColumn[] fields)
        {
            return this.SelectDataTable(TdoSqlExpression.Empty, out dataAdapter, this.pTdoHelper.Transaction, true, fields);
        }
        /// <summary>
        /// Create an instance of DataTable class using search criteria.
        /// </summary>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>DataTable</returns>
        public virtual DataTable SelectDataTable(params ITdoColumn[] fields)
        {
            return this.SelectDataTable(TdoSqlExpression.Empty, fields);
        }
        /// <summary>
        /// Create an instance of DataTable classusing search criteria.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="dataAdapter">SqlDataAdapter for dataset operations.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>DataTable</returns>
        public virtual DataTable SelectDataTable(string clauses, out SqlDataAdapter dataAdapter, params ITdoColumn[] fields)
        {
            return this.SelectDataTable(clauses, out dataAdapter, this.pTdoHelper.Transaction, true, fields);
        }
        /// <summary>
        /// Create an instance of DataTable class using search criteria.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>DataTable</returns>
        public virtual DataTable SelectDataTable(string clauses, params ITdoColumn[] fields)
        {
            SqlDataAdapter da;
            return this.SelectDataTable(clauses, out da, this.pTdoHelper.Transaction, false, fields);
        }
        /// <summary>
        /// Execute a Select 'Top 1' on Table and assign results only for first returned record.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <returns>true record exists, else false.</returns>
        public virtual bool SelectFirstRow(string clauses)
        {
            DataTable dt = this.SelectDataTable(clauses, Functions.Top(1));
            if (dt.Rows.Count > 0)
            {
                foreach (ITdoColumn column in this.pTdoColumns)
                {
                    column.ObjectValue = dt.Rows[0][column.ColumnName];
                }
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// Select Identity field if exists using search criteria. Return identity actualValue.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <returns>identity actualValue</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider")]
        public virtual SqlInt32 SelectIdentity(string clauses)
        {
            //Prepare statement
            string sqlselect = "";
            ITdoColumn identityColumn = null;
            foreach (ITdoColumn column in this.pTdoColumns)
            {
                if (column.AutoIncrement)
                {
                    identityColumn = column;
                    break;
                }
            }
            if (identityColumn == null) throw new InvalidOperationException(String.Format("No Identity column found in {0} Entity", this.TdoColumns[0].TdoEntity.EntityName));
            sqlselect = "select " + identityColumn.ColumnName + " from " + this.FullEntityName + " ";
            //Add where clause
            sqlselect += " " + clauses;
            //prepare query
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            this.TdoHelper.PrepareAutomaticConnection();
            sqlCommand.Parameters.AddRange(this.TdoParameterCollection.ParameterCollection.ToArray());
            //execute query
            this.TdoParameterCollection.Reset();
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            object ris = sqlCommand.ExecuteScalar();
            this.TdoHelper.UnPrepareAutomaticConnection();
            if (ris == null || ris == DBNull.Value)
                return SqlInt32.Null;
            return new SqlInt32(Convert.ToInt32(ris));
        }
        /// <summary>
        /// Select one or more record(s) from Table using search criteria and return XML.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="forXmlClause">Clause FOR XML (Auto or AutoElements)</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>XmlDataReader for reading results in XML Format.</returns>
        public virtual XmlReader SelectXmlReader(string clauses, string forXmlClause, params ITdoColumn[] fields)
        {
            return this.SelectXmlReader(clauses, forXmlClause, this.ColumnNamesOrValues(fields));
        }

        /// <summary>
        /// Select one or more record(s) from Table using search criteria and return XML.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="forXmlClause">Clause FOR XML (Auto or AutoElements)</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Xml.XmlReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectXmlReader(AsyncCallback callBack, object stateObject, string clauses, string forXmlClause, params ITdoColumn[] fields)
        {
            return this.BeginSelectXmlReader(callBack, stateObject, clauses, forXmlClause, this.ColumnNamesOrValues(fields));
        }

        /// <summary>
        /// Initiates the asynchronous execution of the Select FOR XML statement using search criteria, and retrieves one result set from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="forXmlClause">Clause FOR XML</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Xml.XmlReader instance which can be used to retrieve the returned rows.</returns>
        public virtual IAsyncResult BeginSelectXmlReader(AsyncCallback callBack, object stateObject, string forXmlClause, params ITdoColumn[] fields)
        {
            return this.BeginSelectXmlReader(callBack, stateObject, TdoSqlExpression.Empty, forXmlClause, fields);
        }

        /// <summary>
        /// Initiates the asynchronous execution of the Select FOR XML statement using search criteria, and retrieves one result set from the server.
        /// </summary>
        /// <param name="callBack">An System.AsyncCallback delegate that will be invoked when the command's execution has completed. Pass null (Nothing in Visual Basic) to indicate that no callBack is needed.</param>
        /// <param name="stateObject">A user-defined state object that will be passed to the callBack procedure. Retrieve this object from within the callBack procedure using the System.IAsyncResult.AsyncState property.</param>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="forXmlClause">Clause FOR XML</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>An System.IAsyncResult that can be used to poll and/or wait for results; this value is also needed when invoking EndSelectDataReader(), which returns a System.Xml.XmlReader instance which can be used to retrieve the returned rows.</returns>
        private IAsyncResult BeginSelectXmlReader(AsyncCallback callBack, object stateObject, string clauses, string forXmlClause, string fields)
        {
            //Prepare statement
            string sqlselect = "";
            sqlselect = "select " + fields + " from " + this.FullSelectEntityName() + " ";
            //Add clauses
            sqlselect += " " + clauses;
            //Add For XML clause
            sqlselect += " " + forXmlClause;
            //prepare query
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            this.TdoHelper.PrepareAutomaticConnection();
            sqlCommand.CommandTimeout = this.pCommandTimeOut;
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            sqlCommand.Parameters.AddRange(this.TdoParameterCollection.ParameterCollection.ToArray());
            //execute query
            this.TdoParameterCollection.Reset();

            AsyncCallback tdoAsyncCallback = new AsyncCallback(this.internalAsyncCommandTerminated);
            TdoStateObject tdoStateObject = new TdoStateObject(callBack, stateObject, "SelectXmlReader");

            ((ITdoHelper)this.TdoHelper).SqlCommandAsyncStore.Add(tdoStateObject.AsyncCommandUniqueIdentifier, sqlCommand);
            IAsyncResult asyncResult = sqlCommand.BeginExecuteXmlReader(tdoAsyncCallback, tdoStateObject);
            return asyncResult;
        }
        /// <summary>
        /// Select one or more record(s) from Table using search criteria and return XML.
        /// </summary>
        /// <param name="clauses">Tdo.Common.TdoSqlExpressionDom.Clause.[Where|OrderBy|GroupBy](TdoSqlExpression clause). Use overloaded language operators to generate TdoSqlExpression clause.</param>
        /// <param name="forXmlClause">Clause FOR XML</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>XmlDataReader for reading results in XML Format.</returns>
        private XmlReader SelectXmlReader(string clauses, string forXmlClause, string fields)
        {
            //Prepare statement
            string sqlselect = "";
            sqlselect = "select " + fields + " from " + this.FullSelectEntityName() + " ";
            //Add clauses
            sqlselect += " " + clauses;
            //Add For XML clause
            sqlselect += " " + forXmlClause;
            //prepare query
            SqlCommand sqlCommand = this.TdoHelper.CreateCommand(sqlselect);
            this.TdoHelper.PrepareAutomaticConnection();
            sqlCommand.CommandTimeout = this.pCommandTimeOut;
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.internalTdoCommandStatementCompleted);
            sqlCommand.StatementCompleted += new StatementCompletedEventHandler(this.TdoHelper.internalStatementCompletedEventHandler);
            sqlCommand.Parameters.AddRange(this.TdoParameterCollection.ParameterCollection.ToArray());
            //execute query
            this.TdoParameterCollection.Reset();
            return sqlCommand.ExecuteXmlReader();
        }
        /// <summary>
        /// Select one or more record(s) from Table using search criteria and return XML.
        /// </summary>
        /// <param name="forXmlClause">Clause FOR XML</param>
        /// <param name="fields">fields to select. Leave empty for 'Select *'</param>
        /// <returns>XmlDataReader for reading results in XML Format.</returns>
        public virtual XmlReader SelectXmlReader(string forXmlClause, params ITdoColumn[] fields)
        {
            //Returns all records - select *
            return this.SelectXmlReader(TdoSqlExpression.Empty, forXmlClause, fields);
        }
        /// <summary>
        /// Returns full entity name.
        /// </summary>
        /// <returns>string with full entity name.</returns>
        protected internal virtual string FullSelectEntityName()
        {
            return String.Concat(this.SchemaName, ".", this.EntityName);
        }
        /// <summary>
        /// TdoTableBase class destructor
        /// </summary>
        public void Dispose()
        {
            if (this.Disposed!=null)
                this.Disposed(this, EventArgs.Empty);
            GC.SuppressFinalize(this);
        }
        /// <summary>
        /// Occurs during Fill operations with errors.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields")]
        public event FillErrorEventHandler FillError;
        private void internalFillErrorEventHandler(object sender, FillErrorEventArgs e)
        {
            if (this.FillError != null)
                this.FillError(sender, e);
        }
        /// <summary>
        /// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires. 
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields")]
        public event SqlRowUpdatedEventHandler RowUpdated;
        private void internalRowUpdatedEventHandler(object sender, SqlRowUpdatedEventArgs e)
        {
            if (this.RowUpdated != null)
                this.RowUpdated(sender, e);
        }
        /// <summary>
        /// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires. 
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields")]
        public event SqlRowUpdatingEventHandler RowUpdating;
        private void internalRowUpdatingEventHandler(object sender, SqlRowUpdatingEventArgs e)
        {
            if (this.RowUpdating != null)
                this.RowUpdating(sender, e);
        }
        #endregion Methods
        #region Events and Events Handlers
        /// <summary>
        /// Occurs after a command is executed against the data source. 
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2235:MarkAllNonSerializableFields")]
        public event StatementCompletedEventHandler StatementCompleted;
        internal void internalTdoCommandStatementCompleted(object sender, StatementCompletedEventArgs e)
        {
            if (this.StatementCompleted != null)
                this.StatementCompleted(sender, e);
        }
        #endregion Events and Events Handlers
        #region OnDeserialization
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1801:AvoidUnusedParameters"), OnDeserialized()]
        private void OnDeserializedMethod(StreamingContext context)
        {
            //Restore SqlConnection object by recreating from pConnectionString
            this.pTdoParameterCollection = new TdoParameterCollection();
        }
        #endregion OnDeserialization

        #region IComponent Members

        /// <summary>
        /// Disposed event.
        /// </summary>
        public event EventHandler Disposed;

        /// <summary>
        /// Gets or sets the <see cref="T:System.ComponentModel.ISite"></see> associated with the <see cref="T:System.ComponentModel.IComponent"></see>.
        /// </summary>
        /// <value></value>
        /// <returns>The <see cref="T:System.ComponentModel.ISite"></see> object associated with the component; or null, if the component does not have a site.</returns>
        [XmlIgnore()]
        public ISite Site
        {
            get
            {
                return this.iSite;
            }
            set
            {
                this.iSite = value;
            }
        }

        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.