/// <inheritdoc /> public override void LoadInstance(IGenericColumns source, ProductInstance target) { var watch = (WatchInstance)target; watch.TimeSet = source.Integer1 == 1; watch.DeliveryDate = DateTime.FromBinary(source.Integer2); }
public bool HasChanged(IGenericColumns storage, object instance) { // Compare JSON and mappers to entity var json = JsonConvert.SerializeObject(instance, _jsonSettings); return(JsonAccessor.ReadProperty(storage) != json || _configuredMappers.Any(m => m.HasChanged(storage, instance))); }
/// <inheritdoc /> public override void SaveType(IProductType source, IGenericColumns target) { var watch = (WatchType)source; target.Float1 = watch.Weight; target.Float2 = watch.Price; }
/// <inheritdoc /> public override void LoadType(IGenericColumns source, IProductType target) { var watch = (WatchType)target; watch.Weight = source.Float1; watch.Price = source.Float2; }
public bool HasChanged(IGenericColumns current, object updated) { var objectValue = ObjectAccessor.ReadProperty(updated); var columnValue = ColumnAccessor.ReadProperty(current); return(!columnValue.Equals(objectValue)); }
/// <inheritdoc /> public override bool HasChanged(IProductType current, IGenericColumns dbProperties) { var watch = (WatchType)current; return(Math.Abs(watch.Weight - dbProperties.Float1) > 0.01 || Math.Abs(watch.Price - dbProperties.Float2) > 0.01); }
/// <inheritdoc /> public override void SaveInstance(ProductInstance source, IGenericColumns target) { var watch = (WatchInstance)source; target.Integer1 = watch.TimeSet ? 1 : 0; target.Integer2 = watch.DeliveryDate.ToBinary(); }
public void WriteValue(object source, IGenericColumns target) { // Convert and write JSON var json = JsonConvert.SerializeObject(source, _jsonSettings); JsonAccessor.WriteProperty(target, json); // Execute property mappers foreach (var mapper in _configuredMappers) { mapper.WriteValue(source, target); } }
public void ReadValue(IGenericColumns source, object target) { // Use all configured mappers var properties = source; foreach (var mapper in _configuredMappers) { mapper.ReadValue(properties, target); } // Fill the rest from JSON var json = JsonAccessor.ReadProperty(source); if (!string.IsNullOrEmpty(json)) { JsonConvert.PopulateObject(json, target, _jsonSettings); } }
public void ReadValue(IGenericColumns source, object target) { }
/// <inheritdoc /> public sealed override void LoadInstance(IGenericColumns source, ProductInstance target) { // Nothing }
public bool HasChanged(IGenericColumns current, object updated) { return(false); }
public override void LoadRecipe(IGenericColumns source, IProductRecipe target) { EntityMapper.ReadValue(source, target); }
/// <inheritdoc /> public sealed override void SaveInstance(ProductInstance source, IGenericColumns target) { // Not necessary }
public override void SavePartLink(IProductPartLink source, IGenericColumns target) { var link = (NeedlePartLink)source; target.Integer1 = (int)link.Role; }
public override void SaveRecipe(IProductRecipe source, IGenericColumns target) { EntityMapper.WriteValue(source, target); }
public override void SavePartLink(IProductPartLink source, IGenericColumns target) { EntityMapper.WriteValue(source, target); }
public void ReadValue(IGenericColumns source, object target) { var value = ColumnAccessor.ReadProperty(source); ObjectAccessor.WriteProperty(target, value); }
public void WriteValue(object source, IGenericColumns target) { }
public void WriteValue(object source, IGenericColumns target) { var value = ObjectAccessor.ReadProperty(source); ColumnAccessor.WriteProperty(target, value); }
public override bool HasChanged(IProductType current, IGenericColumns dbProperties) { return(EntityMapper.HasChanged(dbProperties, current)); }
public override void SaveInstance(ProductInstance source, IGenericColumns target) { EntityMapper.WriteValue(source, target); }
public override void SavePartLink(IProductPartLink source, IGenericColumns target) { // We have no custom properties }
public override void LoadPartLink(IGenericColumns linkEntity, IProductPartLink target) { var link = (NeedlePartLink)target; link.Role = (NeedleRole)linkEntity.Integer1; }
public override void LoadPartLink(IGenericColumns linkEntity, IProductPartLink target) { EntityMapper.ReadValue(linkEntity, target); }
public override void LoadInstance(IGenericColumns source, ProductInstance target) { EntityMapper.ReadValue(source, target); }
public override void LoadPartLink(IGenericColumns linkEntity, IProductPartLink target) { // We have no custom properties }