コード例 #1
0
        public void Update(DbCustomer customer)
        {
            if (!Data.ContainsKey(customer.Id))
            {
                // Emulate a SQL error
                throw new SqlException("KNF"); //KeyNotFound
            }

            // use the customer id to trigger some special cases
            switch (customer.Id)
            {
                case 42:
                    // Emulate a SQL error
                    throw new SqlException("TO"); // Timeout
                case 43:
                    // Emulate a SQL error
                    throw new SqlException("AE");  // AuthenticationError
                default:
                    Data[customer.Id] = customer;
                    break;
            }
        }
コード例 #2
0
        public void Insert(DbCustomer customer)
        {
            if (Data.ContainsKey(customer.Id))
            {
                // Emulate a SQL error
                throw new SqlException("DK");  // DuplicateKey
            }

            // use the customer id to trigger some special cases
            switch (customer.Id)
            {
            case 42:
                // Emulate a SQL error
                throw new SqlException("TO");      // Timeout

            case 43:
                // Emulate a SQL error
                throw new SqlException("AE");      // AuthenticationError

            default:
                Data[customer.Id] = customer;
                break;
            }
        }