/// <summary>
        /// Get the list of primary key names in the table
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="metadataAccess"></param>
        /// <returns>LIst of primary keys for the specified table</returns>
        private List <string> GetTablePrimaryKeys(string tableName, OleDbMetadataAccess metadataAccess)
        {
            List <string> primaryKeys = new List <string>();
            //get the list of indexes for the table
            DataTable indexList = metadataAccess.GetTableIndexInformation(tableName);

            //check that the table even has an index
            if (indexList != null && indexList.Rows.Count != 0)
            {
                //find the primary key values and add them to the list
                foreach (DataRow index in indexList.Rows)
                {
                    if (Convert.ToBoolean(index["PRIMARY_KEY"]))
                    {
                        primaryKeys.Add(index["COLUMN_NAME"].ToString());
                    }
                }
            }

            return(primaryKeys);
        }
        /// <summary>
        /// Get the list of primary key names in the table
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="metadataAccess"></param>
        /// <returns>LIst of primary keys for the specified table</returns>
        private List<string> GetTablePrimaryKeys(string tableName, OleDbMetadataAccess metadataAccess)
        {
            List<string> primaryKeys = new List<string>();
            //get the list of indexes for the table
            DataTable indexList = metadataAccess.GetTableIndexInformation(tableName);

            //check that the table even has an index
            if (indexList != null && indexList.Rows.Count != 0)
            {
                //find the primary key values and add them to the list
                foreach (DataRow index in indexList.Rows)
                {
                    if (Convert.ToBoolean(index["PRIMARY_KEY"]))
                    {
                        primaryKeys.Add(index["COLUMN_NAME"].ToString());
                    }
                }
            }

            return primaryKeys;
        }
        /// <summary>
        /// Get a specific Object's definition, this includes any attributes and supporting object properties.
        /// In this case retrieve the table definition along with any columns and the definition of each.
        /// </summary>
        /// <param name="methodInput">Method Input which includes an 'ObjectName'
        /// property to determine the object to retrieve the definition for.</param>
        /// <returns>Method Result which will either include error information or the
        /// Object Definition of the 'ObjectName' specified in the MethodInput properties</returns>
        public MethodResult GetObjectDefinition(MethodInput methodInput)
        {
            //Create a new instance of the method result to
            //fill with meta data information
            MethodResult result = new MethodResult();

            //create a new instance of the metadata access class and
            //pass the data access instance allong with it
            OleDbMetadataAccess metadataAccess = new OleDbMetadataAccess(_dataAccess);

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            //is written during garbage collection.
            using (new LogMethodExecution(
                       Globals.ConnectorName, "GetObjectDefinitionMethod"))
            {
                //get the name of the object in the input properties
                string objectName = GetPropertyValue(
                    "ObjectName", methodInput.Input.Properties);

                //using the meta data access get the definitions
                //for each of the columns in the table
                DataTable tableColumnDefinitions =
                    metadataAccess.GetColumnDefinitions(objectName);

                //using the meta data access get the definition for
                //the table indexes (primary and foreign keys)
                DataTable tableIndexDefinition =
                    metadataAccess.GetTableIndexInformation(objectName);

                //check that both sets of data have been
                //returned from the meta data access layer
                if ((tableColumnDefinitions != null &&
                     tableColumnDefinitions.Rows.Count != 0) &&
                    (tableIndexDefinition != null &&
                     tableIndexDefinition.Rows.Count != 0))
                {
                    //create a new replication service object
                    RSObjectDefinition rsObjectDefinition = new RSObjectDefinition()
                    {
                        Name = objectName,
                        RSPropertyDefinitions = new List <RSPropertyDefinition>()
                    };

                    List <string> tablePrimaryKeys =
                        GetTablePrimaryKeys(rsObjectDefinition.Name, metadataAccess);

                    //parse through each column return from the column definitions and
                    //add a new replication service property definition to the newly created
                    //replication service object definition for each column in the table
                    foreach (DataRow columnDefinition in tableColumnDefinitions.Rows)
                    {
                        //process the column definition and set it
                        //to the resplication service property definition
                        RSPropertyDefinition rsPropertyDefinition =
                            ProcessColumnDefinition(columnDefinition);

                        //check if this is the default last
                        //modified column and set the object property
                        if (rsPropertyDefinition.Name == LastModifiedFieldName)
                        {
                            rsObjectDefinition.ModificationDateFullName =
                                rsPropertyDefinition.Name;
                        }

                        //check if the property is a primary key value
                        rsPropertyDefinition.InPrimaryKey =
                            tablePrimaryKeys.Contains(rsPropertyDefinition.Name);

                        //add the property definition to the object definition
                        rsObjectDefinition.RSPropertyDefinitions.Add(rsPropertyDefinition);
                    }

                    //Convert the replication service object definition to a Data Entity
                    //set the result return value to the replication service object defintion
                    //set the result success to true
                    result = new MethodResult {
                        Success = true, Return = rsObjectDefinition.ToDataEntity()
                    };
                }
                else
                {
                    result = new MethodResult {
                        Success = false, ErrorInfo = new ErrorResult {
                            Description = ErrorCodes.ObjectNotFound.Description, Number = ErrorCodes.ObjectNotFound.Number
                        }
                    };
                }
            }

            //return the method result
            return(result);
        }
        /// <summary>
        /// Get a specific Object's definition, this includes any attributes and supporting object properties.
        /// In this case retrieve the table definition along with any columns and the definition of each.
        /// </summary>
        /// <param name="methodInput">Method Input which includes an 'ObjectName' 
        /// property to determine the object to retrieve the definition for.</param>
        /// <returns>Method Result which will either include error information or the 
        /// Object Definition of the 'ObjectName' specified in the MethodInput properties</returns>
        public MethodResult GetObjectDefinition(MethodInput methodInput)
        {
            //Create a new instance of the method result to
            //fill with meta data information
            MethodResult result = new MethodResult();

            //create a new instance of the metadata access class and
            //pass the data access instance allong with it
            OleDbMetadataAccess metadataAccess = new OleDbMetadataAccess(_dataAccess);

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            //is written during garbage collection.
            using (new LogMethodExecution(
                Globals.ConnectorName, "GetObjectDefinitionMethod"))
            {
                //get the name of the object in the input properties
                string objectName = GetPropertyValue(
                    "ObjectName", methodInput.Input.Properties);

                //using the meta data access get the definitions
                //for each of the columns in the table
                DataTable tableColumnDefinitions =
                    metadataAccess.GetColumnDefinitions(objectName);

                //using the meta data access get the definition for
                //the table indexes (primary and foreign keys)
                DataTable tableIndexDefinition =
                    metadataAccess.GetTableIndexInformation(objectName);

                //check that both sets of data have been
                //returned from the meta data access layer
                if ((tableColumnDefinitions != null
                    && tableColumnDefinitions.Rows.Count != 0)
                    && (tableIndexDefinition != null
                    && tableIndexDefinition.Rows.Count != 0))
                {
                    //create a new replication service object
                    RSObjectDefinition rsObjectDefinition = new RSObjectDefinition()
                    {
                        Name = objectName,
                        RSPropertyDefinitions = new List<RSPropertyDefinition>()
                    };

                    List<string> tablePrimaryKeys =
                        GetTablePrimaryKeys(rsObjectDefinition.Name, metadataAccess);

                    //parse through each column return from the column definitions and
                    //add a new replication service property definition to the newly created
                    //replication service object definition for each column in the table
                    foreach (DataRow columnDefinition in tableColumnDefinitions.Rows)
                    {
                        //process the column definition and set it
                        //to the resplication service property definition
                        RSPropertyDefinition rsPropertyDefinition =
                            ProcessColumnDefinition(columnDefinition);

                        //check if this is the default last
                        //modified column and set the object property
                        if (rsPropertyDefinition.Name == LastModifiedFieldName)
                        {
                            rsObjectDefinition.ModificationDateFullName =
                                rsPropertyDefinition.Name;
                        }

                        //check if the property is a primary key value
                        rsPropertyDefinition.InPrimaryKey =
                            tablePrimaryKeys.Contains(rsPropertyDefinition.Name);

                        //add the property definition to the object definition
                        rsObjectDefinition.RSPropertyDefinitions.Add(rsPropertyDefinition);
                    }

                    //Convert the replication service object definition to a Data Entity
                    //set the result return value to the replication service object defintion
                    //set the result success to true
                    result = new MethodResult { Success = true, Return = rsObjectDefinition.ToDataEntity() };
                }
                else
                {
                    result = new MethodResult { Success = false, ErrorInfo = new ErrorResult { Description = ErrorCodes.ObjectNotFound.Description, Number = ErrorCodes.ObjectNotFound.Number } };
                }
            }

            //return the method result
            return result;
        }