1033为英语,2052为中文
public static int? GetCurrentUserLanguageId(IOrganizationService service, Guid userid)
{
QueryExpression mySavedQuery = new QueryExpression
{
ColumnSet = new ColumnSet("systemuserid", "uilanguageid"),
EntityName = "usersettings",
Criteria = new FilterExpression()
{
FilterOperator = Microsoft.Xrm.Sdk.Query.LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "systemuserid",
Operator = ConditionOperator.Equal,
Values = {userid}
}
}
}
};
EntityCollection ec = service.RetrieveMultiple(mySavedQuery);
if (ec != null && ec.Entities != null && ec.Entities.Count > 0 && ec.Entities[0].Contains("uilanguageid"))
{
return (int)(ec.Entities[0]["uilanguageid"]);
}
else
{
return null;
}
}