private OneToManyRelationshipMetadata GetRelationshipMetadata() { var prefix = LogicalName.Split('_')[0]; return(new OneToManyRelationshipMetadata { ReferencedEntity = LookupTarget, ReferencingEntity = Entity, SchemaName = $"{prefix}_{LookupTarget}_{Entity}_{LogicalName}", AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label(LookupTarget, LanguageCode), Order = 10000 }, CascadeConfiguration = new CascadeConfiguration { Assign = CascadeType.NoCascade, Delete = CascadeType.RemoveLink, Merge = CascadeType.NoCascade, Reparent = CascadeType.NoCascade, Share = CascadeType.NoCascade, Unshare = CascadeType.NoCascade } }); }
/// <summary> /// Returns true if InlineResponseDefault6Value instances are equal /// </summary> /// <param name="other">Instance of InlineResponseDefault6Value to be compared</param> /// <returns>Boolean</returns> public bool Equals(InlineResponseDefault6Value other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( LogicalName == other.LogicalName || LogicalName != null && LogicalName.Equals(other.LogicalName) ) && ( MetadataId == other.MetadataId || MetadataId != null && MetadataId.Equals(other.MetadataId) ) && ( OptionSet == other.OptionSet || OptionSet != null && OptionSet.Equals(other.OptionSet) )); }
public string GetDefaultDataType() { if (LogicalName.Contains("firstname")) { return(DataTypeHelper.FirstName); } if (LogicalName.Contains("lastname")) { return(DataTypeHelper.LastName); } if (LogicalName.Contains("fullname")) { return(DataTypeHelper.Name); } if (LogicalName == "customerid") { return(DataTypeHelper.Customer); } if (LogicalName.Contains("birthday")) { return(DataTypeHelper.DatePast); } if (LogicalName.Contains("country")) { return(DataTypeHelper.Country); } if (LogicalName.Contains("city")) { return(DataTypeHelper.City); } if (LogicalName.Contains("street") || LogicalName.Contains("_line1")) { return(DataTypeHelper.Street); } if (LogicalName.Contains("email")) { return(DataTypeHelper.Email); } if (LogicalName.Contains("phone") || LogicalName.Contains("mobile")) { return(DataTypeHelper.PhoneNumber); } if (EntityName == "account" && LogicalName == "name") { return(DataTypeHelper.CompanyNames); } return(DataTypeHelper.GetValidTypes(TypeCode)[0]); }
/// <summary> /// Compares a Dynamics365Field to another instance. /// </summary> /// <param name="other">The other Dynamics365Field.</param> /// <returns>An integer that indicates whether the instance is less than, equal to or greater than another instance.</returns> public int CompareTo(Dynamics365Field other) { if (other == null) { return(1); } return(LogicalName.CompareTo(other.LogicalName)); }
public override bool Equals(object obj) { if (obj is EntityModel entityModel && !string.IsNullOrWhiteSpace(entityModel.LogicalName)) { return(LogicalName?.Equals(entityModel.LogicalName, StringComparison.CurrentCultureIgnoreCase) == true); } return(false); }
/// <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); } }
public override int GetHashCode() { unchecked { var hashCode = (LogicalName != null ? LogicalName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HostName != null ? HostName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HostGuid.GetHashCode(); return(hashCode); } }
public void Not_Decorated_Entity_Name_Test() { // Setup string expectedEntityName = nameof(NotDecoratedEntity).ToLowerInvariant(); // Act string actuaEntityName = LogicalName.GetName <NotDecoratedEntity>(); // Assert Assert.AreEqual(expectedEntityName, actuaEntityName); }
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)); }
/// <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 int CompareTo(Dynamics365Entity other) { if (other == null) { return(1); } else { return(LogicalName.CompareTo(other.LogicalName)); } }
/// <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>(); }
public void Get_Names_Test() { // Setup string expected1 = nameof(TestEntity.ReferenceTypeProperty).ToLower(); string expected2 = nameof(TestEntity.ValueTypeProperty).ToLower(); // Act List <string> actual = LogicalName.GetNames <TestEntity>( t => t.ReferenceTypeProperty, t => t.ValueTypeProperty); // Assert Assert.AreEqual(2, actual.Count); Assert.AreEqual(expected1, actual[0]); Assert.AreEqual(expected2, actual[1]); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (LogicalName != null) { hashCode = hashCode * 59 + LogicalName.GetHashCode(); } if (MetadataId != null) { hashCode = hashCode * 59 + MetadataId.GetHashCode(); } if (OptionSet != null) { hashCode = hashCode * 59 + OptionSet.GetHashCode(); } return(hashCode); } }
protected override void Execute(CodeActivityContext eContext) { var lookup = LookupAttribute.Get(eContext); var orgurl = OrgUrl.Get(eContext); var context = eContext.GetExtension<IWorkflowContext>(); var serviceFactory = eContext.GetExtension<IOrganizationServiceFactory>(); var service = serviceFactory.CreateOrganizationService(context.UserId); var reference = GetReference(service, lookup, new EntityReference(context.PrimaryEntityName, context.PrimaryEntityId)); // Update Reference Information if (reference == null) return; ID.Set(eContext, reference.Id.ToString()); LogicalName.Set(eContext, reference.LogicalName); // Update URL Information if (string.IsNullOrWhiteSpace(orgurl)) return; var url = CreateUrl(orgurl, reference); URL.Set(eContext, url); HtmlLink.Set(eContext, CreateHtmlLink(service, reference, url, LinkText.Get(eContext))); }
public void Get_Name_For_Oob_Generated() { // Setup string expectedString = nameof(Account.AccountNumber).ToLowerInvariant(); string expectedDouble = nameof(Account.Address1_Longitude).ToLowerInvariant(); string expectedOptionSet = nameof(Account.AccountRatingCode).ToLowerInvariant(); string expectedInt = nameof(Account.Address1_UTCOffset).ToLowerInvariant(); string expectedMoney = nameof(Account.CreditLimit).ToLowerInvariant(); string expectedBool = nameof(Account.CreditOnHold).ToLowerInvariant(); string expectedDate = nameof(Account.CreatedOn).ToLowerInvariant(); string expectedGuid = nameof(Account.AccountId).ToLowerInvariant(); string expectedReference = nameof(Account.PrimaryContactId).ToLowerInvariant(); string expectedDecimal = nameof(Account.ExchangeRate).ToLowerInvariant(); // Act List <string> actual = LogicalName.GetNames <Account>( a => a.AccountNumber, a => a.Address1_Longitude, a => a.AccountRatingCode, a => a.Address1_UTCOffset, a => a.CreditLimit, a => a.CreditOnHold, a => a.CreatedOn, a => a.AccountId, a => a.PrimaryContactId, a => a.ExchangeRate); // Assert Assert.AreEqual(expectedString, actual[0]); Assert.AreEqual(expectedDouble, actual[1]); Assert.AreEqual(expectedOptionSet, actual[2]); Assert.AreEqual(expectedInt, actual[3]); Assert.AreEqual(expectedMoney, actual[4]); Assert.AreEqual(expectedBool, actual[5]); Assert.AreEqual(expectedDate, actual[6]); Assert.AreEqual(expectedGuid, actual[7]); Assert.AreEqual(expectedReference, actual[8]); Assert.AreEqual(expectedDecimal, actual[9]); }
/// <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 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)); }
public int CompareTo(Object obj) { return(LogicalName.CompareTo(obj)); }
/// <summary> /// Adds the specified attributes to the column set. /// </summary> /// <typeparam name="T">Type of the entity to add column from</typeparam> /// <param name="column">The property expressions containing the name of the attribute to add</param> public static void AddColumns <T>(this ColumnSet columnSet, params Expression <Func <T, object> >[] columns) where T : Entity { columnSet.AddColumns(LogicalName.GetNames(columns)?.ToArray()); }
/// <summary> /// Adds the specified attributes to the column set. /// </summary> /// <param name="columns">Specifies an array of property expressions containing the names of the attributes.</param> public void AddColumns(params Expression <Func <T, object> >[] columns) { Columns.AddRange(LogicalName.GetNames(columns)); }
/// <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> /// Initializes a new instance of the ColumnSet<T> class setting the Columns property. /// </summary> /// <param name="columns">Specifies an array of property expressions containing the names of the attributes. /// </param> public ColumnSet(params Expression <Func <T, object> >[] columns) { Columns = LogicalName.GetNames(columns); }
/// <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)); }
public override int GetHashCode() { return(LogicalName == null?base.GetHashCode() : LogicalName.GetHashCode()); }
/// <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); }