Skip to content

Commit

Permalink
Check both sides of a relation are not virtual at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
circles-arrows committed Feb 26, 2024
1 parent 8f7be4f commit 4e7060f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Blueprint41/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ public Entity Abstract(bool isAbstract = true)
}
public Entity Virtual(bool isVirtual = true)
{
EntityProperty? rel = Properties.FirstOrDefault(item => item.ForeignEntity is not null && item.ForeignEntity.IsVirtual);
if (rel is not null)
throw new InvalidOperationException($"In and Out sides of the relation '{rel.Name}' cannot be virtual at the same time.");

IsVirtual = isVirtual;

return this;
Expand Down
3 changes: 3 additions & 0 deletions Blueprint41/Relationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ internal Relationship(DatastoreModel parent, string name, string? neo4JRelations
if (outEntity is not null && outInterface is not null)
throw new ArgumentException("You cannot have both the outEntity and the outInterface set at the same time.");

if ((inEntity?.IsVirtual ?? false) && (outEntity?.IsVirtual ?? false))
throw new InvalidOperationException($"In and Out sides of the relation '{name}' cannot be virtual at the same time.");

_self = new IEntity[] { this };
_properties = new PropertyCollection(this);
Properties = new EntityPropertyCollection<RelationshipProperty, Relationship>(this, _properties);
Expand Down

0 comments on commit 4e7060f

Please sign in to comment.