Пример #1
0
        public EntityBuilder FromManyToManyRelation(Attributes.ManyToMany rel)
        {
            var builder = new EntityBuilder(_context)
            {
                ClrType = null, EntityName = rel.RelationTableName, _tableName = rel.RelationTableName,
            };

            return(builder);
        }
Пример #2
0
        public void Build()
        {
            var relation = _relation switch
            {
                Attributes.OneToOne a => new OneToOne(FromEntity, ToEntity, FromKeyAttribute, FromEntityAttribute,
                                                      ToKeyAttribute, ToEntityAttribute) as IRelation,
                Attributes.ManyToOne b => new ManyToOne(FromEntity, ToEntity, FromKeyAttribute, FromEntityAttribute,
                                                        ToKeyAttribute, ToEntityAttribute),
                Attributes.OneToMany c => new OneToMany(FromEntity, ToEntity, FromKeyAttribute, FromEntityAttribute,
                                                        ToKeyAttribute, ToEntityAttribute),
                Attributes.ManyToMany c => new ManyToMany(FromEntity, ToEntity, FromKeyAttribute, FromEntityAttribute,
                                                          ToKeyAttribute, ToEntityAttribute, BetweenEntity, ReferencedFromAttribute, ReferencedToAttribute),
                _ => throw new ArgumentException(nameof(_relation))
            };

            relation.FromEntityAttribute.Relation = relation;
            _context.Relations.GetOrInsert(relation.FromEntity.EntityName, new Dictionary <string, IRelation>())[
                relation.FromEntityAttribute.PropertyName] = relation;
        }
    }