当我运行下面的代码时,它会添加记录,但一开始它并没有包含在 ContactSet 中。只有当我再次运行它时,它才会显示在 ContactSet 上,并且它显示一次,除了我得到重复记录的事实。知道为什么 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 = "allisonbrown@aol.com"
};
xrm.AddObject(testContact);
xrm.SaveChanges();
var exampleContacts = xrm.ContactSet.Where(c => c.EMailAddress1.EndsWith(".com"));
return View(exampleContacts);