private DomainObject CloneObject(DomainObject obj, SessionIdentifier newSession) { DomainPropertyCollection propertyCollection = new DomainPropertyCollection(); //EntityLinkCollection linkCollection = new EntityLinkCollection(); foreach (DomainProperty property in obj.Properties) { DomainProperty newProperty = CloneProperty(property, newSession); propertyCollection.Add(newProperty); } //foreach (EntityLink link in obj.Links) //{ // EntityLink newLink = CloneLink(link, newSession); // linkCollection.Add(newLink); //} DomainObject result = m_objectFactory.CreateDomainObject(newSession, obj.ObjectId); result.Init(propertyCollection); return result; }
public DomainPropertyCollection GetEmptyProperties(SessionIdentifier sessionId, ObjectIdentifier parentId) { DomainObjectConfig obj = m_inquiry.AObject[parentId.Code]; DomainPropertyCollection result = new DomainPropertyCollection(); foreach (DomainPropertyConfig prop in obj.Property) { DomainProperty newProperty = new DomainProperty(sessionId, parentId, prop.Code, prop.DefaultValue); result.Add(newProperty); } return result; }
private DomainPropertyCollection LoadProperties(SessionIdentifier sessionId, ObjectIdentifier objectId) { string objCode = objectId.Code; DomainObjectConfig objConfig = m_inquiry.AObject[objCode]; DomainObjectBroker broker = GetObjectBroker(objCode); long[] idList = new long[] { objectId.Id }; DbCommonCommand command = broker.LoadItemsCommand; command["ID"].Value = idList; DomainPropertyCollection result = null; using (IDbCommonDataReader reader = command.ExecuteReader(sessionId)) { if (!reader.Read()) { reader.Close(); throw new DomainException(String.Format("Объект {0} не найден в БД", objectId)); } result = new DomainPropertyCollection(); foreach (DomainPropertyConfig prop in objConfig.Property) { object value = reader.GetValue(reader.GetOrdinal(prop.Code), prop.DataType); DomainProperty newProperty = new DomainProperty(sessionId, objectId, prop.Code, value); result.Add(newProperty); } reader.Close(); } return result; }
/// <summary> /// Init properties and set object state to Old /// </summary> /// <param name="properties"></param> internal void Init(DomainPropertyCollection properties) { // Save object properties Properties = properties; AssignPropertyEvents(); // Set object state to Old State |= eObjectState.Old; }