Skip to content

Commit

Permalink
馃Ч Tiny refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed May 1, 2020
1 parent d1c98aa commit 36fa4c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 3 additions & 7 deletions FetchXmlBuilder/AppCode/EntityRelationship.cs
Expand Up @@ -8,17 +8,16 @@ namespace Cinteros.Xrm.FetchXmlBuilder.AppCode
public class EntityRelationship : IComparable
{
public RelationshipMetadataBase Relationship;
public EntityRole Role;
public string Name = "";

public EntityRelationship(RelationshipMetadataBase relation, EntityRole role, string originatingEntity, FetchXmlBuilder fxb, string originatingParent = "")
{
Relationship = relation;
Role = role;

if (relation is OneToManyRelationshipMetadata)
if (relation is OneToManyRelationshipMetadata om)
{
var om = (OneToManyRelationshipMetadata)relation;

if (role == EntityRole.Referenced)
{
Name = fxb.GetEntityDisplayName(om.ReferencedEntity) + "." + om.ReferencedAttribute + " <- " +
Expand All @@ -30,10 +29,8 @@ public EntityRelationship(RelationshipMetadataBase relation, EntityRole role, st
fxb.GetEntityDisplayName(om.ReferencedEntity) + "." + om.ReferencedAttribute;
}
}
else if (relation is ManyToManyRelationshipMetadata)
else if (relation is ManyToManyRelationshipMetadata mm)
{
var mm = (ManyToManyRelationshipMetadata)relation;

if (fxb.NeedToLoadEntity(mm.Entity1LogicalName))
{
fxb.LoadEntityDetails(mm.Entity1LogicalName, null, false);
Expand Down Expand Up @@ -73,7 +70,6 @@ public EntityRelationship(RelationshipMetadataBase relation, EntityRole role, st
}
}
}
public EntityRole Role { get; set; }

public override string ToString()
{
Expand Down
7 changes: 2 additions & 5 deletions FetchXmlBuilder/Controls/linkEntityControl.cs
Expand Up @@ -174,9 +174,8 @@ private void cmbRelationship_SelectedIndexChanged(object sender, EventArgs e)
string to;
bool intersect;

if (rel.Relationship is OneToManyRelationshipMetadata)
if (rel.Relationship is OneToManyRelationshipMetadata om)
{
var om = (OneToManyRelationshipMetadata)rel.Relationship;
if (parent == om.ReferencedEntity && rel.Role == EntityRole.Referenced)
{
entity = om.ReferencingEntity;
Expand All @@ -196,10 +195,8 @@ private void cmbRelationship_SelectedIndexChanged(object sender, EventArgs e)
}
intersect = false;
}
else if (rel.Relationship is ManyToManyRelationshipMetadata)
else if (rel.Relationship is ManyToManyRelationshipMetadata mm)
{
var mm = (ManyToManyRelationshipMetadata)rel.Relationship;

if (fxb.NeedToLoadEntity(mm.Entity1LogicalName))
{
fxb.LoadEntityDetails(mm.Entity1LogicalName, null, false);
Expand Down

0 comments on commit 36fa4c1

Please sign in to comment.