当前位置: 首页>>代码示例>>C#>>正文


C# Customer.SetAssignedIdTo方法代码示例

本文整理汇总了C#中Customer.SetAssignedIdTo方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.SetAssignedIdTo方法的具体用法?C# Customer.SetAssignedIdTo怎么用?C# Customer.SetAssignedIdTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customer的用法示例。


在下文中一共展示了Customer.SetAssignedIdTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanCompareCustomers

        public void CanCompareCustomers()
        {
            Customer customerA = new Customer("Acme");
            Customer customerB = new Customer("Anvil");

            Assert.AreNotEqual(customerA, null);
            Assert.AreNotEqual(customerA, customerB);

            customerA.SetAssignedIdTo("AAAAA");
            customerB.SetAssignedIdTo("AAAAA");

            // Even though the "business value signatures" are different, the persistent IDs
            // were the same.  Call me crazy, but I put that much trust into IDs.
            Assert.AreEqual(customerA, customerB);

            Customer customerC = new Customer("Acme");

            // Since customerA has an ID but customerC doesn't, their signatures will be compared
            Assert.AreEqual(customerA, customerC);

            customerC.ContactName = "Coyote";

            // Signatures are now different
            Assert.AreNotEqual(customerA, customerC);

            // customerA.Equals(customerB) because they have the same ID.
            // customerA.Equals(customerC) because they have the same signature.
            // ! customerB.Equals(customerC) because we can't compare their IDs,
            // since customerC is transient, and their signatures are different.
            Assert.AreNotEqual(customerB, customerC);
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:31,代码来源:CustomerTests.cs

示例2: Create

        public Customer Create(string companyName, string assignedId)
        {
            var customerToCreate = new Customer(companyName);
            customerToCreate.SetAssignedIdTo(assignedId);

            this.customerRepository.DbContext.BeginTransaction();
            this.customerRepository.SaveOrUpdate(customerToCreate);
            this.customerRepository.DbContext.CommitTransaction();

            return customerToCreate;
        }
开发者ID:seif,项目名称:Northwind,代码行数:11,代码来源:CustomerTasks.cs

示例3: btnAdd_OnClick

    protected void btnAdd_OnClick(object sender, EventArgs e) {
        if (txtCustomerID.Text.Trim().Length == 5) {
            Customer newCustomer = new Customer(txtCompanyName.Text);
            newCustomer.SetAssignedIdTo(txtCustomerID.Text);
            newCustomer.ContactName = txtContactName.Text;

            IDaoFactory daoFactory = new NHibernateDaoFactory();
            ICustomerDao customerDao = daoFactory.GetCustomerDao();

            if (!IsDuplicateOfExisting(newCustomer, customerDao)) {
                customerDao.Save(newCustomer);
                Response.Redirect("ListCustomers.aspx?action=added");
            }
            else {
                lblMessage.Text =
                    "<span style=\"color:red\">The ID you provided is already in use.</span><br />Please change the ID and try again.";
            }
        }
        else {
            lblMessage.Text =
                "<span style=\"color:red\">The ID you provide must be exactly 5 characters long.</span><br />Please change the ID and try again.";
        }
    }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:23,代码来源:AddCustomer.aspx.cs

示例4: CreatePersistedCustomer

        private Customer CreatePersistedCustomer(string customerId, string contactName, string companyName, string country) {
            Customer customer = new Customer(companyName) {
                ContactName = contactName,
                Country = country
            };
            customer.SetAssignedIdTo(customerId);

            // We have to explicitly call Save() since it has an assigned ID
            customerRepository.Save(customer);
            FlushSessionAndEvict(customer);

            return customer;
        }
开发者ID:EdisonCP,项目名称:sharp-architecture,代码行数:13,代码来源:CustomerRepositoryTests.cs


注:本文中的Customer.SetAssignedIdTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。