Exemple #1
0
 private TypedRelations GetPredefinedRelations(PredefinedRelationType relationType, Entity entity)
 {
     IEnumerable<Entity> relatedEntities = relationType.GetRelatedEntities (entity).Where (e => !e.IsDeleted);
     return new TypedRelations (relationType)
     {
         Relations = relatedEntities.ToDictionary<Entity, Relation, Entity> (e => new Relation (), e => e)
     };
 }
Exemple #2
0
 private void AddPredefinedRelation(PredefinedRelationType relationType, Entity entity, Entity relatedEntity)
 {
     IEnumerable<Entity> relatedEntities = relationType.GetRelatedEntities (entity);
     if (!relatedEntities.Contains (relatedEntity))
     {
         // Even though the type of objectiveEntities is IEnumerable<Entity>, it is sure that it is also
         // ICollection<relationType.ObjectiveEntityType> so the Add method is surely found.
         MethodInfo add = relatedEntities.GetType ().GetMethod ("Add");
         add.Invoke (relatedEntities, new object[] { relatedEntity });
         Db.SaveChanges ();
     }
 }