private void Init <TParent>(TParent parent, string property) where TParent : IEntity { if (DB.DatabaseName <TParent>() != DB.DatabaseName <TChild>()) { throw new NotSupportedException("Cross database relationships are not supported!"); } this.parent = parent; isInverse = false; JoinCollection = DB.GetRefCollection <TParent>($"[{DB.CollectionName<TParent>()}~{DB.CollectionName<TChild>()}({property})]"); CreateIndexesAsync(JoinCollection); }
/// <summary> /// Gets the name of the database this entity is attached to. Returns name of default database if not specifically attached. /// </summary> public static string DatabaseName <T>(this T _) where T : IEntity => DB.DatabaseName <T>();
/// <summary> /// Gets the name of the database this entity is attached to. Returns name of default database if not specifically attached. /// </summary> public static string DatabaseName <T>(this T _) where T : IEntity { return(DB.DatabaseName <T>()); }