Compartir a través de


RetrieveEntityRequest Class

Definition

Contains the data that is needed to retrieve the definition of a table.

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

The following RetrieveTableById and RetrieveTableByName static methods both use the OutputTableDefinitionProperties method to show details of the table definition.

/// <summary>
/// Retrieves a table definition by ID
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void RetrieveTableById(IOrganizationService service)
{

    Guid keyID = new("70816501-edb9-4740-a16c-6a5efbc05d84");

    RetrieveEntityRequest request = new()
    {
        MetadataId = keyID
        EntityFilters = EntityFilters.Entity
    };

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

    OutputTableDefinitionProperties(response.EntityMetadata);

}

/// <summary>
/// Retrieves a table definition by by name
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void RetrieveTableByName(IOrganizationService service)
{
    string logicalName = "account";

    RetrieveEntityRequest request = new()
    {
        LogicalName = logicalName,
        EntityFilters = EntityFilters.Entity
    };

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

    OutputTableDefinitionProperties(response.EntityMetadata);
}

//Outputs details about retrieved table definition
static void OutputTableDefinitionProperties(EntityMetadata tableDefinition)
{
    Console.WriteLine($"SchemaName:{tableDefinition.SchemaName}");
    Console.WriteLine($"DisplayName:{tableDefinition.DisplayName.UserLocalizedLabel.Label}");
    Console.WriteLine($"LogicalName:{tableDefinition.LogicalName}");           
}

Output:

SchemaName:Account
DisplayName:Account
LogicalName:account

Remarks

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of RetrieveEntityResponse.

Privileges and Access Rights

Table definition information is available for all users.

Notes for Callers

You can use either the LogicalName or the MetadataId properties to specify the table definitions you want to retrieve.

Constructors

RetrieveEntityRequest()

Initializes a new instance of the RetrieveEntityRequest class.

Properties

EntityFilters

Gets or sets a filter to control how much data for the entity is retrieved.

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)
LogicalName

Gets or sets the logical name of the table to retrieve. Optional.

MetadataId

Gets or sets the unique identifier for the entity. Optional.

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)
RetrieveAsIfPublished

Gets or sets whether to retrieve the table definition data that has not been published.

Applies to