예제 #1
0
        public DataObjectCollection <T> RegisterEntityCollection <T>(IDataObjectCollectionLoader <T> loader = null) where T : DataObject
        {
            if (_resolveReferences.ContainsKey(typeof(T)))
            {
                throw new ArgumentException(" An DataObjectSet with that name already exists.");
            }
            var entityCollection = new DataObjectCollection <T>(() => this, loader);

            _resolveReferences.Add(typeof(T), entityCollection);
            return(entityCollection);
        }
예제 #2
0
        private IDataObjectCollection CreateRelationWhenNotExist <T>(string relationName, long foreignKey) where T : DataObject
        {
            if (foreignKey == 0)
            {
                return(new DataObjectCollection <T>(() => this));
            }
            if (!_foreignKeys.ContainsKey(relationName))
            {
                _foreignKeys[relationName] = new Dictionary <long, IDataObjectCollection>();
            }
            var entityCollections = _foreignKeys[relationName];

            if (!entityCollections.ContainsKey(foreignKey))
            {
                entityCollections[foreignKey] = new DataObjectCollection <T>(() => this);
            }
            var relation = entityCollections[foreignKey];

            return(relation);
        }