CRUDOperations.vb中的这行代码有什么作用?

时间:2012-10-18 17:35:49

标签: vb.net sdk dynamics-crm dynamics-crm-2011

以下是Microsoft Dynamics CRM 2011 SDK中CRUDOperations.vb文件的一些代码:

  ' Retrieve the account containing several of its attributes.
  Dim cols As New ColumnSet(New String() { "name", "address1_postalcode", "lastusedincampaign" })
  Dim retrievedAccount As Account = CType(_service.Retrieve("account", _accountId, cols), Account)
  Console.Write("retrieved, ")
  ' Update the postal code attribute.
  retrievedAccount.Address1_PostalCode = "98052"
  ' The address 2 postal code was set accidentally, so set it to null.
  retrievedAccount.Address2_PostalCode = Nothing

现在,如果我理解正确,请按以下一行:

      Dim retrievedAccount As Account = CType(_service.Retrieve("account", _accountId, cols), Account)

似乎没有做任何事情?

1 个答案:

答案 0 :(得分:4)

  1. 调用_service.Retrieve("account", _accountId, cols)
  2. 它将返回值强制转换为Account类型。
  3. 它将返回值存储在变量retrievedAccount
  4. 然后后续行修改retrievedAccount引用的帐户的属性。