1
當我運行下面的代碼時,它添加了記錄但它並沒有包含在ContactSet中。只有當我再次運行它時,它會顯示在ContactSet上,並且只顯示一次,除了我獲得重複記錄的事實。任何想法爲什麼ContactSet不顯示創建的新記錄?最近添加的記錄不包括在CrmOrganizationServiceContext中ContactSet
var xrm = new XrmServiceContext("Xrm");
//Create a new contact called Allison Brown.
var testContact = new Contact
{
FirstName = "Allison",
LastName = "Brown",
Address1_Line1 = "101 W 1st St",
Address1_City = "Los Angeles",
Address1_StateOrProvince = "CA",
Address1_PostalCode = "90001",
Telephone1 = "310-111-1111",
EMailAddress1 = "[email protected]"
};
xrm.AddObject(testContact);
xrm.SaveChanges();
var exampleContacts = xrm.ContactSet.Where(c => c.EMailAddress1.EndsWith(".com"));
return View(exampleContacts);