Data/CafeLib.Data.Mapping/MappedEntity.cs
/// <summary>
/// Copy values to data model from mapped entity.
/// </summary>
/// <param name="entity"></param>
/// <returns>data model</returns>
Copy values to data model from mapped entity.
Copy values to data model from mapped entity .
public TModel Populate(TEntity entity)
        {
            var dto = entity ?? throw new ArgumentNullException(nameof(entity));
            foreach (var entityProperty in EntityProperties.Values)
            {
                var propertyConverter = _propertyConverters[entityProperty.Name];
                var modelProperty = propertyConverter?.PropertyInfo;
                if (modelProperty == null || !modelProperty.CanWrite || modelProperty.GetSetMethod() == null) continue;
                var value = propertyConverter.ToProperty != null
                    ? ((Delegate)propertyConverter.ToProperty).DynamicInvoke(entityProperty.GetValue(dto))
                    : entityProperty.GetValue(dto);
                modelProperty.SetValue(this, value);
            }
            return (TModel)(object)this;
        }
public TModel Populate ( TEntity entity ) { var dto = entity ?? throw new ArgumentNullException ( nameof ( entity ) ) ; foreach ( var entityProperty in EntityProperties . Values ) { var propertyConverter = _propertyConverters [ entityProperty . Name ] ; var modelProperty = propertyConverter ? . PropertyInfo ; if ( modelProperty == null || ! modelProperty . CanWrite || modelProperty . GetSetMethod ( ) == null ) continue ; var value = propertyConverter . ToProperty != null ? ( ( Delegate ) propertyConverter . ToProperty ) . DynamicInvoke ( entityProperty . GetValue ( dto ) ) : entityProperty . GetValue ( dto ) ; modelProperty . SetValue ( this , value ) ; } return ( TModel ) ( object ) this ; }
Copy values to data model from mapped entity.
Copy values to data model from mapped entity .
None
entity
TEntity
None