Inheritance: global::System.ComponentModel.Component
Exemplo n.º 1
0
        /// <summary>
        /// The GetDocument verb retuns an complete AccountDocument containing the data associated with
        /// an existing account instance.
        ///
        /// Should no account instance be found in the data-store that matches the identity
        /// passed as a parameter it will return an empty account document marked as deleted within the given identity. 
        /// </summary>
        /// <param name="identity">Identity of the account</param>
        /// <param name="lastToken">the last given Token to mark the account status as updated or created</param>
        /// <param name="config">The configuration object</param>
        /// <returns>an account document</returns>
        public override Document GetDocument(Identity identity, Token lastToken, NorthwindConfig config)
        {
            #region declarations
            int recordCount;
            AccountsTableAdapter tableAdapter;
            AccountDataset account = new AccountDataset();
            #endregion

            // get the Account by the given identity
            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                tableAdapter = new AccountsTableAdapter();
                tableAdapter.Connection = connection;
                recordCount = tableAdapter.FillBy(account.Accounts, identity.Id);
            }

            // when the record does not exists return an deleted document of the given identity
            if (recordCount == 0)
                return GetDeletedDocument(identity);

            // convert the dataset row to an account document and return it
            return GetDocument((AccountDataset.AccountsRow)account.Accounts[0], lastToken, config);
        }
Exemplo n.º 2
0
        public override List<Identity> GetAll(NorthwindConfig config, string whereExpression, OleDbParameter[] oleDbParameters)
        {
            #region Declarations
            List<Identity> result = new List<Identity>();
            int recordCount = 0;
            AccountDataset dataset = new AccountDataset();
            #endregion

            // get the first 11 rows of the changelog
            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                AccountsTableAdapter tableAdapter;

                tableAdapter = new AccountsTableAdapter();

                tableAdapter.Connection = connection;

                HandleDelimiterClause(ref whereExpression);
                if (string.IsNullOrEmpty(whereExpression))
                    recordCount = tableAdapter.Fill(dataset.Accounts);
                else
                    recordCount = tableAdapter.FillByWhereClause(dataset.Accounts, whereExpression, oleDbParameters);
            }

            foreach (AccountDataset.AccountsRow row in dataset.Accounts.Rows)
            {
                // use where expression !!
                result.Add(new Identity(this.EntityName, row.ID));
            }

            return result;
        }