public T GetRelation <T>(DDDBuildingBlock DDDObject) { if (_DDDToEFRelations.TryGetValue(DDDObject, out var dbObjectList)) { return((T)dbObjectList.FirstOrDefault(x => x.GetType() == typeof(T))); } return(default);
public List <object> GetRelations(DDDBuildingBlock DDDObject) { if (_DDDToEFRelations.TryGetValue(DDDObject, out var dbObjectList)) { return(dbObjectList); } return(null); }
public void AddRelation(DDDBuildingBlock DDDObject, params object[] DBObject) { if (_DDDToEFRelations.TryGetValue(DDDObject, out var dbObjectList)) { dbObjectList.AddRange(DBObject); } else { _DDDToEFRelations.Add(DDDObject, DBObject.ToList()); } }
public void AddRelation(DDDBuildingBlock DDDObject, object DBObject) { if (_DDDToEFRelations.TryGetValue(DDDObject, out var dbObjectList)) { dbObjectList.Add(DBObject); } else { _DDDToEFRelations.Add(DDDObject, new List <object>() { DBObject }); } }
public static TDbObject MapToDbObject <TDbObject>(IMapper mapper, MappingManager mappingManager, DDDBuildingBlock entity, Func <DDDBuildingBlock, bool> equalityComparer = null) { if (entity is not DDDBuildingBlock) { throw new ArgumentException($"{nameof(entity)} is not ${nameof(DDDBuildingBlock)} type"); } if (mappingManager.MappingExist(entity, equalityComparer)) { var fromContext = mappingManager.GetRelation <TDbObject>(entity, equalityComparer); mapper.Map(entity, fromContext); return(fromContext); } return(mapper.Map <TDbObject>(entity)); }