AliasedValue AliasedValue AliasedValue AliasedValue Class

Definition

Used to return aggregate, group by, and aliased values from a query.

public ref class AliasedValue sealed : System::Runtime::Serialization::IExtensibleDataObject
[System.Runtime.Serialization.DataContract(Name="AliasedValue", Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
[System.Runtime.Serialization.KnownType("GetKnownAliasedValueTypes")]
public sealed class AliasedValue : System.Runtime.Serialization.IExtensibleDataObject
type AliasedValue = class
    interface IExtensibleDataObject
Public NotInheritable Class AliasedValue
Implements IExtensibleDataObject
Inheritance
AliasedValueAliasedValueAliasedValueAliasedValue
Attributes
Implements

Examples

// Fetch the average of estimatedvalue for all opportunities.  This is the equivalent of 
                    // SELECT AVG(estimatedvalue) AS estimatedvalue_avg ... in SQL.
                    System.Console.WriteLine("===============================");
                    string estimatedvalue_avg = @" 
                    <fetch distinct='false' mapping='logical' aggregate='true'> 
                        <entity name='opportunity'> 
                           <attribute name='estimatedvalue' alias='estimatedvalue_avg' aggregate='avg' /> 
                        </entity> 
                    </fetch>";

                    EntityCollection estimatedvalue_avg_result = svc.RetrieveMultiple(new FetchExpression(estimatedvalue_avg));

                    foreach (var c in estimatedvalue_avg_result.Entities)
                    {
                        decimal aggregate1 = ((Money)((AliasedValue)c["estimatedvalue_avg"]).Value).Value;
                        System.Console.WriteLine("Average estimated value: " + aggregate1);

                    }
// Fetch the average of estimatedvalue for all opportunities.  This is the equivalent of 
                    // SELECT AVG(estimatedvalue) AS estimatedvalue_avg ... in SQL.
                    System.Console.WriteLine("===============================");
                    string estimatedvalue_avg = @" 
                    <fetch distinct='false' mapping='logical' aggregate='true'> 
                        <entity name='opportunity'> 
                           <attribute name='estimatedvalue' alias='estimatedvalue_avg' aggregate='avg' /> 
                        </entity> 
                    </fetch>";

                    EntityCollection estimatedvalue_avg_result = svc.RetrieveMultiple(new FetchExpression(estimatedvalue_avg));

                    foreach (var c in estimatedvalue_avg_result.Entities)
                    {
                        decimal aggregate1 = ((Money)((AliasedValue)c["estimatedvalue_avg"]).Value).Value;
                        System.Console.WriteLine("Average estimated value: " + aggregate1);

                    }

Constructors

AliasedValue() AliasedValue() AliasedValue() AliasedValue()

Initializes a new instance of the AliasedValue class.

AliasedValue(String, String, Object) AliasedValue(String, String, Object) AliasedValue(String, String, Object) AliasedValue(String, String, Object)

Initializes a new instance of the AliasedValue class.

Properties

AttributeLogicalName AttributeLogicalName AttributeLogicalName AttributeLogicalName

Gets the name of the attribute on which the aggregate, group by, or select operation was performed.

EntityLogicalName EntityLogicalName EntityLogicalName EntityLogicalName

Gets the name of the entity the attribute belongs to.

ExtensionData ExtensionData ExtensionData ExtensionData

Gets or sets the structure that contains extra data.

Value Value Value Value

Gets the value returned by the query.

Applies to