|
@@ -34,11 +34,21 @@ namespace InABox.Core
|
|
|
{
|
|
|
private IProperty _property;
|
|
|
|
|
|
- public Type Type => _property.PropertyType;
|
|
|
+ public Type Type
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (Expression is null)
|
|
|
+ throw new Exception($"Expression [{Property}] may not be null");
|
|
|
+ if (Expression is IndexExpression)
|
|
|
+ return DatabaseSchema.Property(typeof(T), Property).PropertyType;
|
|
|
+ return Expression.Type;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- public string Property => _property.Name;
|
|
|
+ public string Property { get; private set; }
|
|
|
|
|
|
- public Expression Expression => _property.Expression();
|
|
|
+ public Expression Expression { get; private set; }
|
|
|
|
|
|
public bool IsEqualTo(string name) =>
|
|
|
!name.IsNullOrWhiteSpace() && Property.Equals(name);
|
|
@@ -50,19 +60,25 @@ namespace InABox.Core
|
|
|
|
|
|
public Column(IProperty property)
|
|
|
{
|
|
|
- _property = property;
|
|
|
+ Property = property.Name;
|
|
|
+ Expression = property.Expression();
|
|
|
}
|
|
|
|
|
|
public Column(Expression<Func<T, object?>> expression)
|
|
|
{
|
|
|
- _property = DatabaseSchema.Property(expression)
|
|
|
- ?? throw new Exception($"Property {CoreUtils.GetFullPropertyName(expression, ".")} not found.");
|
|
|
+ Property = CoreUtils.GetFullPropertyName(expression, ".");
|
|
|
+ Expression = CoreUtils.ExtractMemberExpression(expression);
|
|
|
}
|
|
|
|
|
|
public Column(string property)
|
|
|
{
|
|
|
- _property = DatabaseSchema.Property(typeof(T), property)
|
|
|
- ?? throw new Exception($"Property {property} not found.");
|
|
|
+ Property = property;
|
|
|
+
|
|
|
+ var iprop = DatabaseSchema.Property(typeof(T), property);
|
|
|
+ if (iprop != null)
|
|
|
+ Expression = iprop.Expression();
|
|
|
+ else
|
|
|
+ Expression = CoreUtils.CreateMemberExpression(typeof(T), property);
|
|
|
}
|
|
|
|
|
|
public Column<TNew> Cast<TNew>()
|
|
@@ -106,40 +122,6 @@ namespace InABox.Core
|
|
|
IEnumerator<IColumn> GetEnumerator();
|
|
|
}
|
|
|
|
|
|
- public enum ColumnType
|
|
|
- {
|
|
|
- //ExcludeVisible,
|
|
|
- /// <summary>
|
|
|
- /// Do not include <see cref="Entity.ID"/> in the columns.
|
|
|
- /// </summary>
|
|
|
- ExcludeID,
|
|
|
- IncludeOptional,
|
|
|
- IncludeForeignKeys,
|
|
|
- /// <summary>
|
|
|
- /// Include all columns that are accessible through entity links present in the root class.
|
|
|
- /// </summary>
|
|
|
- IncludeLinked,
|
|
|
- IncludeAggregates,
|
|
|
- IncludeFormulae,
|
|
|
- /// <summary>
|
|
|
- /// Include any columns that are a <see cref="CustomProperty"/>.
|
|
|
- /// </summary>
|
|
|
- IncludeUserProperties,
|
|
|
- /// <summary>
|
|
|
- /// Include all columns that are accessible through entity links, even nested ones.
|
|
|
- /// </summary>
|
|
|
- IncludeNestedLinks,
|
|
|
- IncludeEditable,
|
|
|
- /// <summary>
|
|
|
- /// Add all columns that are data actually on the entity, and not on entity links or calculated fields.
|
|
|
- /// </summary>
|
|
|
- DataColumns,
|
|
|
- /// <summary>
|
|
|
- /// Add all columns found.
|
|
|
- /// </summary>
|
|
|
- All
|
|
|
- }
|
|
|
-
|
|
|
[Flags]
|
|
|
public enum ColumnTypeFlags
|
|
|
{
|