/// <summary> /// Resolves the ids. /// </summary> /// <exception cref="System.InvalidOperationException">ids was null</exception> public void ResolveIds( ) { var idMap = new Dictionary <long, long>( ); foreach (JsonEntityRef er in EntityRefs.Where(er => er.Id >= BaseNewId)) { if (idMap.ContainsKey(er.Id)) { er.Id = idMap[er.Id]; } else if (!string.IsNullOrEmpty(er.Alias)) { long id = new EntityRef(er.NameSpace, er.Alias).Id; if (id > 0) { idMap[er.Id] = id; er.Id = idMap[er.Id]; } } } if (Ids == null) { throw new InvalidOperationException("ids was null"); } Ids = Ids.Select(p => ResolveId(p, idMap)).ToList( ); Entities.ForEach(p => p.ResolveIds(idMap)); }
/// <summary> /// Gets the entity reference. /// </summary> /// <param name="entityRef">The entity reference.</param> /// <returns></returns> public JsonEntityRef GetEntityRef(EntityRef entityRef) { JsonEntityRef jsonEntityRef = EntityRefs.FirstOrDefault(p => p.Id == entityRef.Id); if (jsonEntityRef == null) { jsonEntityRef = new JsonEntityRef(entityRef); EntityRefs.Add(jsonEntityRef); } return(jsonEntityRef); }