private static void LoadGraph <T>(T obj, ActiveRecordMap activeRecordMap) where T : class, IActiveRecord, new() { foreach (BelongsToMap belongsToMap in activeRecordMap.BelongsToMappings) { IRelationship relationship = (IRelationship)belongsToMap.Field.GetValue(obj); relationship.Load(); } foreach (HasOneMap hasOneMap in activeRecordMap.HasOneMappings) { IRelationship relationship = (IRelationship)hasOneMap.Field.GetValue(obj); relationship.Load(); } foreach (HasManyMap hasManyMap in activeRecordMap.HasManyMappings) { IRelationship relationship = (IRelationship)hasManyMap.Field.GetValue(obj); relationship.Load(); } foreach (HasAndBelongsToManyMap hasAndBelongsToManyMap in activeRecordMap.HasAndBelongsToManyMappings) { IRelationship relationship = (IRelationship)hasAndBelongsToManyMap.Field.GetValue(obj); relationship.Load(); } }
public void Load(Dictionary data) { Dictionary tempDict = this.ValueExtractor.GetValueFromDictionary <Dictionary>(data, "Relationships"); foreach (DictionaryEntry entry in tempDict) { ICollection <Dictionary> relationshipDicts = this.ValueExtractor.GetCollectionFromArray <Dictionary>(entry.Value as Array); foreach (Dictionary relationshipDict in relationshipDicts) { var name = this.ValueExtractor.GetValueFromDictionary <string>(relationshipDict, "Name"); IRelationship relationship = this.RelationshipTypes .FirstOrDefault(r => r.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); relationship?.Load(relationshipDict); if (relationship is null) { continue; } this.m_Relationships.Add(long.Parse(entry.Key.ToString()), relationship); } } }