本文整理汇总了C#中XrmServiceContext.Create方法的典型用法代码示例。如果您正苦于以下问题:C# XrmServiceContext.Create方法的具体用法?C# XrmServiceContext.Create怎么用?C# XrmServiceContext.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XrmServiceContext
的用法示例。
在下文中一共展示了XrmServiceContext.Create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: bw_DoWork
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
XrmServiceContext xrm;
xrm = new XrmServiceContext("Xrm");
foreach (MyLead objLead in Leads)
{
//xrm.AddObject(objLead);
Guid objLeadGuid = xrm.Create(objLead);//Using this method as opposed to xrm.AddObject results in getting the GUID required to add a note to the lead.
//This method also adds the Lead Object to the Db.
objLead.Note.ObjectId = new Microsoft.Xrm.Client.CrmEntityReference("lead", objLeadGuid); //Creates the xref between the Annotation object (the note) and the lead
xrm.AddObject(objLead.Note); //adds the note to the CRM Database..
}
xrm.SaveChanges();//this saves all the notes to the database. The leads are automatically saved by calling the Create() method...
}