/// <summary> /// Method that synchronizes the current graph with the provided graph by copying properties and entity states /// from the entities in give graph to the current graph. All property values in the current graph will be overwritten with /// the property values form the entities in srcGraph (i.e., this method has load behavior LoadBehavior.RefreshCurrent). /// </summary> /// <param name="srcGraph">The graph to synchronize from</param> public void Synchronize(EntityGraph srcGraph) { if (EntityGraphEqual(srcGraph, EntityTypeComparer) == false) { throw new Exception("Source graph entity graph must be a copy or a clone of present entity graph."); } var elements = srcGraph.Zip(this, (src, tgt) => new { src = src, tgt = tgt }); foreach (var pair in elements) { RefreshCurrent(pair.src, pair.tgt); } }
/// <summary> /// Method that synchronizes the current graph with the provided graph by copying properties and entity states /// from the entities in give graph to the current graph. The way that property values are merged is specified by loadBehavior. /// </summary> /// <param name="srcGraph">The graph to synchronize from</param> /// <param name="loadBehavior">The LoadBehavior to apply. When specifying LoadBehavior.KeepCurrent, Synchronize will have no effect.</param> public void Synchronize(EntityGraph srcGraph, LoadBehavior loadBehavior) { if (loadBehavior == LoadBehavior.KeepCurrent) { return; } if (loadBehavior == LoadBehavior.RefreshCurrent) { Synchronize(srcGraph); } if (EntityGraphEqual(srcGraph, EntityTypeComparer) == false) { throw new Exception("Source graph entity graph must be a copy or a clone of present entity graph."); } var elements = srcGraph.Zip(this, (src, tgt) => new { src = src, tgt = tgt }); foreach (var pair in elements) { MergeIntoCurrent(pair.src, pair.tgt); } }
/// <summary> /// Determines whether two entity graphs are clones of eachother by member-wise comparing all entities in both graphs. /// </summary> /// <param name="graph"></param> /// <returns></returns> public bool IsCloneOf(EntityGraph graph) { return(EntityGraphEqual(graph, (e1, e2) => e1 != e2 && MemberwiseCompare(e1, e2, true))); }
/// <summary> /// Determines whether two entity graphs are copies of eachother by member-wise comparing all entities in both graphs. /// </summary> /// <param name="graph"></param> /// <returns></returns> public bool IsCopyOf(EntityGraph graph) { return(EntityGraphEqual(graph, (e1, e2) => e1 != e2 && MemberwiseCompare(e1, e2, false))); }