共用方式為


CreateEntityKeyRequest Class

Definition

Contains data that is needed to create an alternate key.

public ref class CreateEntityKeyRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class CreateEntityKeyRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type CreateEntityKeyRequest = class
    inherit OrganizationRequest
Public NotInheritable Class CreateEntityKeyRequest
Inherits OrganizationRequest
Inheritance
CreateEntityKeyRequest
Attributes

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance.

/// <summary>
/// Demonstrates creating an alternate key for a table
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void CreateEntityKey(IOrganizationService service) {

      string prefix = "sample";
      string tableLogicalName = $"{prefix}_bankaccount";
      string columnLogicalName = $"{prefix}_name";
      string alternateKeySchemaName = $"{prefix}_UniqueName";
      string alternateKeyDisplayName = "Unique Name";
      int languagecode = 1033; //English
      string solutionUniqueName = "SolutionName";

      EntityKeyMetadata metadata = new() {
         KeyAttributes = new string[] { columnLogicalName },
         SchemaName = alternateKeySchemaName,
         DisplayName = new Label(alternateKeyDisplayName, languagecode)
      };

      CreateEntityKeyRequest request = new() { 
         EntityName = tableLogicalName,
         EntityKey = metadata,
         SolutionUniqueName = solutionUniqueName
      };

      var response = (CreateEntityKeyResponse)service.Execute(request);

      Console.WriteLine($"EntityKeyId: {response.EntityKeyId}");

}         

Remarks

This message takes the entity name and EntityKeyMetadata values as input to create the key.

Usage

When you pass an instance of this class to the Execute(OrganizationRequest) method, it returns an instance of the RetrieveEntityKeyResponse class.

Constructors

CreateEntityKeyRequest()

Initializes a new instance of the CreateEntityKeyRequest class.

Properties

EntityKey

Gets or sets the entity key.

EntityName

Gets or sets the entity name.

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
SolutionUniqueName

Gets or sets the unique name of the solution.

Applies to