Clase de LabelQueryExpression
Se aplica a: CRM 2015 on-prem, CRM Online
Defines the languages for the labels to be retrieved for metadata items that have labels.
Espacio de nombres: Microsoft.Xrm.Sdk.Metadata.Query
Ensamblado: Microsoft.Xrm.Sdk (en Microsoft.Xrm.Sdk.dll)
Sintaxis
'Declaración
<DataContractAttribute(Name:="LabelQueryExpression", Namespace:="https://schemas.microsoft.com/xrm/2011/Metadata/Query")> _
Public NotInheritable Class LabelQueryExpression
Inherits MetadataQueryBase
[DataContractAttribute(Name="LabelQueryExpression", Namespace="https://schemas.microsoft.com/xrm/2011/Metadata/Query")]
public sealed class LabelQueryExpression : MetadataQueryBase
Comentarios
The number of labels returned for each item depends on the number of language packs installed by the organization. If no additional language packs are installed, there will only be labels for the organization base language. For best performance when additional language packs are installed you can limit labels to those that correspond to the user’s language preference. These preferences can be determined using the values returned by the client-side context getUserLcid function or by querying the UserSettings.UILanguageId value.
The following example shows those portions of the Sample: Query Metadata and Detect Changes which deal with setting the LabelQueryExpression.
private Guid _userId;
private int _languageCode;
...
_userId = ((WhoAmIResponse)_service.Execute(new WhoAmIRequest())).UserId;
_languageCode = RetrieveUserUILanguageCode(_userId);
...
protected int RetrieveUserUILanguageCode(Guid userId)
{
QueryExpression userSettingsQuery = new QueryExpression("usersettings");
userSettingsQuery.ColumnSet.AddColumns("uilanguageid", "systemuserid");
userSettingsQuery.Criteria.AddCondition("systemuserid", ConditionOperator.Equal, userId);
EntityCollection userSettings = _service.RetrieveMultiple(userSettingsQuery);
if (userSettings.Entities.Count > 0)
{
return (int)userSettings.Entities[0]["uilanguageid"];
}
return 0;
}
...
//A label query expression to limit the labels returned to only those for the user's preferred language
LabelQueryExpression labelQuery = new LabelQueryExpression();
labelQuery.FilterLanguages.Add(_languageCode);
Jerarquía heredada
System.Object
Microsoft.Xrm.Sdk.Metadata.Query.MetadataQueryBase
Microsoft.Xrm.Sdk.Metadata.Query.LabelQueryExpression
Seguridad de hilo
Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para el hilo. No se garantiza que los miembros de instancia sean seguros para el hilo.
Plataformas
Plataformas de desarrollo
Windows Vista, Windows Server 2003 y
Plataformas de destino
Windows 98,Windows 2000,Windows 2000 Server,Windows CE,Windows Server 2008,Windows 98 Second Edition,Pocket PC,Teléfono inteligente,Windows Server 2003,Windows XP Professional,Windows Vista,Windows XP
Change History
Vea también
Referencia
Miembros de LabelQueryExpression
Espacio de nombres de Microsoft.Xrm.Sdk.Metadata.Query
Otros recursos
Query and Capture Changes to Metadata
Customize Labels to Support Multiple Languages
Sample: Query Metadata and Detect Changes
Send comments about this topic to Microsoft.
© 2014 Microsoft Corporation. All rights reserved.