本文整理匯總了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());
}