Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, this went to be my solution.</p> <pre><code>public class MyObject { [Key] public int Id { get; set; } public Money MyMoney { get { return (Money)MyMoneyInternal; } set { MyMoneyInternal = (decimal)value; } } private decimal MyMoneyInternal { get; set; } } </code></pre> <p>To be able to read that private property I created a property extension as below. Since some of my properties of type Money is Nullable I had to take care of that as well. </p> <pre><code>public static class PropertyExtensions { public static PrimitivePropertyConfiguration Property&lt;TClass, TProperty&gt;(this EntityTypeConfiguration&lt;TClass&gt; etc, string propertyName) where TClass : class where TProperty : struct { PrimitivePropertyConfiguration returnValue; Type type = typeof(TClass); var propertyInfo = type.GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); ParameterExpression parameterExpression = Expression.Parameter(type, "xyz"); MemberExpression memberExpression = Expression.Property((Expression)parameterExpression, propertyInfo); if (IsNullable(memberExpression.Type)) { returnValue = etc.Property((Expression&lt;Func&lt;TClass, TProperty?&gt;&gt;)Expression.Lambda(memberExpression, parameterExpression)); } else { returnValue = etc.Property((Expression&lt;Func&lt;TClass, TProperty&gt;&gt;)Expression.Lambda(memberExpression, parameterExpression)); } return returnValue; } private static bool IsNullable(Type type) { bool result; if (type.IsGenericType) { var genericType = type.GetGenericTypeDefinition(); result = genericType.Equals(typeof(Nullable&lt;&gt;)); } else { result = false; } return result; } } </code></pre> <p>And then I could use that to read my private property.</p> <pre><code>modelBuilder.Entity&lt;MyObject&gt;() .Property&lt;MyObject, decimal&gt;("MyMoneyInternal").HasColumnName("MyMoney"); </code></pre> <p>Thank you Steve for taking me in the right direction.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload