string[] IEntity.GetModifiedProperties() { return((from s in InnerEntry.GetModifiedProperties() let p = PropertyUnity.GetProperty(_entityType, s) where p != null && (!p.Info.IsPrimaryKey || (p.Info.IsPrimaryKey && p.Info.GenerateType == IdentityGenerateType.None)) select s).ToArray()); }
private void RemoveInnerItemEntry(TInner innerItem, InnerEntry innerEntry) { innerEntry.ReferenceCount--; if (innerEntry.ReferenceCount == 0) { _innerEntries.Remove(innerItem); } }
public BashkraEntry() { InitializeComponent(); InnerEntry.Focused += InnerEntryOnFocused; InnerEntry.Unfocused += InnerEntryOnFocused; GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => InnerEntry.Focus()) }); }
/// <summary> /// 检查并懒加载属性的值。 /// </summary> /// <param name="property"></param> /// <returns></returns> private PropertyValue CheckAndLazyPropertyValue(IProperty property) { var value = PropertyValue.Empty; if (InnerEntry.Has(property.Name)) { value = InnerEntry[property.Name].GetOldValue(); } return(PropertyValue.IsEmpty(value) ? ProcessSupposedProperty(property) : value); }
private void AddInnerItemEntry(TInner innerItem, TKey innerItemKey) { InnerEntry innerEntry; if (!_innerEntries.TryGetValue(innerItem, out innerEntry)) { innerEntry = new InnerEntry(innerItemKey); _innerEntries[innerItem] = innerEntry; } innerEntry.ReferenceCount++; }
void OnInnerRemove(object sender, int index, IEnumerable <TInner> oldItems) { foreach (var innerItem in oldItems) { InnerEntry innerEntry = _innerEntries[innerItem]; RemoveInnerItemFromAllOuterEntriesMatchingKey(innerItem, innerEntry.Key); RemoveInnerItemFromKeyLookup(innerItem, innerEntry.Key); RemoveInnerItemEntry(innerItem, innerEntry); } }
/// <summary> /// 检查是否有原值相等。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> /// <param name="oldValue"></param> /// <returns></returns> private bool CheckValueEquals(IProperty property, PropertyValue value, out PropertyValue oldValue) { if (InnerEntry.Has(property.Name) && (oldValue = (this as IEntity).GetDirectValue(property)) != null) { oldValue.InitializeInstanceName(string.Empty); return(value == oldValue); } oldValue = PropertyValue.Empty; return(false); }
void IEntity.NotifyModified(string propertyName) { InnerEntry.Modify(propertyName); if (state == EntityState.Unchanged) { state = EntityState.Modified; } if (owner != null) { owner.Parent.As <IEntity>(s => s.NotifyModified(owner.Property == null ? string.Empty : owner.Property.Name)); } }
/// <summary> /// 内部设置属性值的方法。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> private void InternalSetValue(IProperty property, PropertyValue value) { if (PropertyValue.IsEmpty(value)) { if (SetNullable(property)) { return; } } if (property is RelationProperty) { InnerLazyMgr.SetValueCreated(property.Name); } InnerEntry.Modify(property.Name, value); }
void IEntityRelation.NotifyModified(string propertyName) { if (!string.IsNullOrEmpty(propertyName)) { InnerEntry.Modify(propertyName); } if (_state == EntityState.Unchanged) { _state = EntityState.Modified; } //修改父对象的状态 if (_owner != null) { _owner.Parent.As <IEntityRelation>(s => s.NotifyModified(_owner.Property == null ? string.Empty : _owner.Property.Name)); } }
/// <summary> /// 处理附加属性的值。 /// </summary> /// <param name="property"></param> /// <returns></returns> private PropertyValue ProcessSupposedProperty(IProperty property) { if (property is RelationProperty relationProperty && relationProperty.Options.LoadBehavior != LoadBehavior.None) { var value = EntityLazyloader.Load(this, relationProperty); if (value != null && !PropertyValue.IsEmpty(value)) { InnerLazyMgr.SetValueCreated(property.Name); value._dataType = property.Info.DataType; InnerEntry.Initializate(property.Name, value); } return(value); } return(PropertyValue.Empty); }
void IEntity.NotifyModified(string propertyName, bool modified) { if (!modified) { InnerEntry.Modify(propertyName, false); return; } InnerEntry.Modify(propertyName, modified); if (_state == EntityState.Unchanged) { _state = EntityState.Modified; } if (_owner != null) { _owner.Parent.As <IEntity>(s => s.NotifyModified(_owner.Property == null ? string.Empty : _owner.Property.Name)); } }
/// <summary> /// 处理附加属性的值。 /// </summary> /// <param name="property"></param> /// <returns></returns> private PropertyValue ProcessSupposedProperty(IProperty property) { var relationProperty = property.As <RelationProperty>(); if (relationProperty != null && relationProperty.Options.LoadBehavior != LoadBehavior.None) { var value = EntityLazyloader.Load(this, relationProperty); InnerLazyMgr.SetValueCreated(property.Name); if (value != null) { InnerEntry.Initializate(property.Name, value, () => value.DataType = property.Info.DataType); } return(value); } return(PropertyValue.Empty); }
/// <summary> /// 克隆出一个新的实体对象。 /// </summary> /// <returns></returns> public object Clone() { var entity = _entityType.New <EntityObject>(); entity.InitializeInstanceName((this.As <IEntityPersistentInstanceContainer>().InstanceName)); entity.InitializeEnvironment(_environment); if (_entityType.IsNotCompiled()) { foreach (var property in PropertyUnity.GetProperties(_entityType)) { var pv = GetValue(property); entity.SetValue(property, pv); } } else { this.TryLockModifing(() => { InnerEntry.ForEach(k => { var property = PropertyUnity.GetProperty(_entityType, k.Key); if (property?.Info.IsPrimaryKey == true) { entity.InnerEntry.Initializate(k.Key, k.Value.GetCurrentValue()); } else { entity.InnerEntry.Modify(k.Key, k.Value.GetCurrentValue()); } }); }); } return(entity); }
PropertyValue IEntity.GetDirectValue(IProperty property) { return(InnerEntry.Has(property.Name) ? InnerEntry[property.Name].GetCurrentValue() : PropertyValue.Empty); }
bool IEntity.IsModified(string propertyName) { return(InnerEntry.Has(propertyName) && InnerEntry[propertyName].IsModified); }
PropertyValue IEntity.GetOldValue(IProperty property) { return(InnerEntry.Has(property.Name) ? InnerEntry[property.Name].GetOldValue() : PropertyValue.Empty); }
void IEntity.ResetUnchanged() { _state = EntityState.Unchanged; InnerEntry.Reset(); }