本文整理汇总了C#中Account.AddContact方法的典型用法代码示例。如果您正苦于以下问题:C# Account.AddContact方法的具体用法?C# Account.AddContact怎么用?C# Account.AddContact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account.AddContact方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Account_WithContacts_VerifyMap
public void Account_WithContacts_VerifyMap()
{
var dealer = session.Get<AccountType>(1);
var phone = session.Get<ContactType>(1);
var email = session.Get<ContactType>(5);
var account = new Account()
{
Name = "Acme Enterprises",
AccountType = dealer,
ModifyDate = DateTime.Now,
ModifyUser = "test"
};
account.AddContact(
new Contact() {
ContactDetail = "[email protected]",
DoNotify = true,
FirstName = "John",
LastName = "Dough",
ContactType = email,
});
account.AddContact(
new Contact() {
ContactDetail = "123-456-7890",
DoNotify = false,
FirstName = "Jane",
LastName = "Dough",
ContactType = phone,
});
session.SaveOrUpdate(account);
session.Flush();
var account2 = session.QueryOver<Account>().Where(a => a.Id == account.Id).SingleOrDefault();
Assert.IsNotNull(account2);
Assert.AreEqual(2, account2.ContactList.Count);
Assert.IsNotNull(account2.ContactList.Where(c => c.ContactDetail == "[email protected]").FirstOrDefault());
}
示例2: SaveAccount_WithContacts
public void SaveAccount_WithContacts()
{
var dealer = session.Get<AccountType>(1);
var phone = session.Get<ContactType>(1);
var email = session.Get<ContactType>(5);
var account = new Account()
{
Name = "Acme Enterprises",
AccountType = dealer,
ModifyDate = DateTime.Now,
ModifyUser = "test"
};
account.AddContact(
new Contact()
{
ContactDetail = "[email protected]",
DoNotify = true,
FirstName = "John",
LastName = "Dough",
ContactType = email,
});
repository.SaveAccount(account);
var account2 = repository.GetAccount(account.Id);
Assert.IsNotNull(account2);
Assert.AreEqual(1, account2.ContactList.Count);
Assert.IsNotNull(account2.ContactList.Where(c => c.ContactDetail == "[email protected]").FirstOrDefault());
}