/// <summary> /// Initializes a new instance of the ConditionExpression<T> class. /// </summary> /// <param name="attributeName">The logical name of the attribute in the condition expression.</param> /// <param name="conditionOperator">The condition operator.</param> /// <param name="values">The array of attribute values.</param> public ConditionExpression(Expression <Func <T, object> > attributeName, ConditionOperator conditionOperator, params object[] values) { EntityName = LogicalName.GetName <T>(); AttributeName = attributeName; Operator = conditionOperator; if (values != null) { Values = new List <object>(values); } }
/// <summary> /// Adds the specified link to the query expression setting the entity name to link /// to, the attribute name to link from and the attribute name to link to.</summary> /// <typeparam name="TFrom">Type of the entity to link from</typeparam> /// <typeparam name="TTo">Type of the entity to link to</typeparam> /// <param name="linkFromAttributeName">The property expressions containing the name of the attribute to link from.</param> /// <param name="linkToAttributeName">The property expressions containing the name of the attribute to link to.</param> public static LinkEntity AddLink <TFrom, TTo>( this QueryExpression query, Expression <Func <TFrom, object> > linkFromAttributeName, Expression <Func <TTo, object> > linkToAttributeName) where TFrom : Entity where TTo : Entity { return(query.AddLink(LogicalName.GetName <TTo>(), LogicalName.GetName(linkFromAttributeName), LogicalName.GetName(linkToAttributeName))); }
public void Get_Value_Type_Property_Name_Test() { // Setup string expected = nameof(TestEntity.ValueTypeProperty).ToLower(); // Act string actual = LogicalName.GetName <TestEntity>(t => t.ValueTypeProperty); // Assert Assert.AreEqual(expected, actual); }
public void Should_Throw_On_Methods_Test() { // Assert ArgumentException e = Assert.ThrowsException <ArgumentException>(() => { // Act LogicalName.GetName <TestEntity>(t => t.ToEntityReference()); }); Assert.IsTrue(e.Message.Contains(CheckParam.InvalidExpression(null).Message)); }
public void Not_Decorated_Entity_Name_Test() { // Setup string expectedEntityName = nameof(NotDecoratedEntity).ToLowerInvariant(); // Act string actuaEntityName = LogicalName.GetName <NotDecoratedEntity>(); // Assert Assert.AreEqual(expectedEntityName, actuaEntityName); }
/// <summary> /// Adds a link, setting the link to entity name, the link from attribute name and /// the link to attribute name. /// </summary> /// <typeparam name="TFrom">Type of the entity to link from</typeparam> /// <typeparam name="TTo">Type of the entity to link to</typeparam> /// <param name="linkToEntityName">The name of the entity to link to.</param> /// <param name="linkFromAttributeName">The property expressions containing the name of the attribute to link from.</param> /// <param name="linkToAttributeName">The property expressions containing the name of the attribute to link to.</param> /// <returns>The link entity that was created.</returns> public static LinkEntity AddLink <TFrom, TTo>( this LinkEntity link, string linkToEntityName, Expression <Func <TFrom, object> > linkFromAttributeName, Expression <Func <TTo, object> > linkToAttributeName) where TFrom : Entity where TTo : Entity { return(link.AddLink( linkToEntityName, LogicalName.GetName <TFrom>(linkFromAttributeName), LogicalName.GetName <TTo>(linkToAttributeName))); }
public void Oob_Entity_Test() { // Setup string expectedName = Account.EntityLogicalName; string expectedName2 = CustomEntity.EnityLogicalName; // Act string actualName = LogicalName.GetName <Account>(); string actualName2 = LogicalName.GetName <CustomEntity>(); // Assert Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedName2, actualName2); }
public void Same_Prop_Name_Test() { // Setup string expectedPropName = "string_prop"; string expectedProp2Name = "string_prop2"; // Act string actualPropName = LogicalName.GetName <CustomEntity>(c => c.StringProp); string actualProp2Name = LogicalName.GetName <CustomEntity2>(c => c.StringProp); // Assert Assert.AreEqual(expectedPropName, actualPropName); Assert.AreEqual(expectedProp2Name, actualProp2Name); }
/// <summary> /// Initializes a new instance of the LinkEntity class setting the required properties. /// </summary> /// <param name="linkFromAttributeName">The name of the attribute to link from.</param> /// <param name="linkToAttributeName">The name of the attribute to link to.</param> /// <param name="joinOperator">The join operator.</param> public LinkEntity( Expression <Func <TFrom, object> > linkFromAttributeName, Expression <Func <TTo, object> > linkToAttributeName, JoinOperator joinOperator) { this.LinkFromEntityName = LogicalName.GetName <TFrom>(); this.LinkToEntityName = LogicalName.GetName <TTo>(); this.LinkFromAttributeName = linkFromAttributeName; this.LinkToAttributeName = linkToAttributeName; this.JoinOperator = joinOperator; this.Columns = new ColumnSet(); this.LinkCriteria = new FilterExpression(); this.Orders = new List <OrderExpression>(); this.LinkEntities = new List <LinkEntity>(); }
/// <summary> /// Adds the specified order expression to the query expression. /// </summary> /// <param name="attributeName">The property expressions containing the name of the attribute</param> /// <param name="orderType">The order for that attribute.</param> public static void AddOrder <T>(this QueryExpression query, Expression <Func <T, object> > attributeName, OrderType orderType) where T : Entity { query.AddOrder(LogicalName.GetName(attributeName), orderType); }
/// <summary> /// Adds a condition to the filter expression setting the entity name, attribute name, condition operator, and value array. /// </summary> /// <typeparam name="T">Type of the entity.</typeparam> /// <param name="attributeName">Property expressions containing the name of the attribute.</param> /// <param name="conditionOperator">Condition operator.</param> /// <param name="values">The array of values to add.</param> public static void AddCondition <T>(this FilterExpression filterExpression, Expression <Func <T, object> > attributeName, ConditionOperator conditionOperator, params object[] values) where T : Entity { filterExpression.AddCondition(LogicalName.GetName <T>(), LogicalName.GetName(attributeName), conditionOperator, values); }
/// <summary> /// Adds the specified attribute to the column set /// </summary> /// <param name="column">Specifies a property expressions containing the name of the attribute.</param> public void AddColumn(Expression <Func <T, object> > column) { Columns.Add(LogicalName.GetName(column)); }
/// <summary> /// Adds an attribute value to the attributes collection. /// </summary> /// <typeparam name="T">Type of the entity</typeparam> /// <param name="attributeName">The property expressions containing the name of the attribute</param> /// <param name="value">The attribute value.</param> public static void AddAttribute <T>(this QueryByAttribute query, Expression <Func <T, object> > attributeName, object value) where T : Entity { query.AddAttributeValue(LogicalName.GetName(attributeName), value); }
/// <summary> /// Adds the specified attribute to the column set. /// </summary> /// <typeparam name="T">Type of the entity to add column from</typeparam> /// <param name="column">The property expression containing the name of the attribute to add</param> public static void AddColumn <T>(this ColumnSet columnSet, Expression <Func <T, object> > column) where T : Entity { columnSet.AddColumn(LogicalName.GetName(column)); }