示例#1
0
 public IEnumerable <E> FetchManyToManyCollection <E>(int ownerId) where E : IModel
 {
     string     ownerName            = typeof(T).Name;
     string     ownedName            = typeof(E).Name;
     string     tableName            = DatebaseUtils.ManyToManyTableName(ownerName, ownedName);
     string     queryManyToManyTable = DatebaseUtils.ManyToManyTableSelectQuery(tableName, ownerId);
     List <int> collectedIds         = this.connectionManager.GetConnection().Query <int> (queryManyToManyTable).ToList();
 }
示例#2
0
        public void SaveManyToManyCollection <E> (int ownerId, List <int> ownedIds) where E : IModel
        {
            string ownerName = typeof(T).Name;
            string ownedName = typeof(E).Name;
            string tableName = DatebaseUtils.ManyToManyTableName(ownerName, ownedName);
            string query     = DatebaseUtils.ManyToManyInsertionQuery(tableName, ownerName, ownedName, ownerId, ownedIds);

            this.connectionManager.GetConnection().Execute(query);
        }
示例#3
0
        public void CreateRelationshipsTables(List <Type> entities)
        {
            List <PropertyInfo> properties;

            string query, owner, owned, tableName;

            manager.Connect();
            foreach (Type entity in entities)
            {
                properties = ReflectionUtils.ListPropertiesWithAttribute <ManyToManyAttribute> (entity);
                foreach (PropertyInfo property in properties)
                {
                    owner     = entity.Name;
                    owned     = property.PropertyType.GetGenericArguments().First().Name;
                    tableName = DatebaseUtils.ManyToManyTableName(owner, owned);
                    query     = DatebaseUtils.ManyToManyTableCreationQuery(tableName, owner, owned);
                    manager.GetConnection().Execute(query);
                }
            }
            manager.Disconnect();
        }