public MListExpression(Type type, PrimaryKeyExpression backID, IntervalExpression?externalPeriod, TableMList tr) : base(DbExpressionType.MList, type) { this.BackID = backID; this.ExternalPeriod = externalPeriod; this.TableMList = tr; }
public EntityExpression(Type type, PrimaryKeyExpression externalId, IntervalExpression?externalPeriod, Alias?tableAlias, IEnumerable <FieldBinding>?bindings, IEnumerable <MixinEntityExpression>?mixins, IntervalExpression?tablePeriod, bool avoidExpandOnRetrieving) : base(DbExpressionType.Entity, type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (!type.IsEntity()) { throw new ArgumentException("type"); } this.Table = Schema.Current.Table(type); this.ExternalId = externalId ?? throw new ArgumentNullException(nameof(externalId)); this.TableAlias = tableAlias; this.Bindings = bindings.ToReadOnly(); this.Mixins = mixins.ToReadOnly(); this.ExternalPeriod = externalPeriod; this.TablePeriod = tablePeriod; this.AvoidExpandOnRetrieving = avoidExpandOnRetrieving; }
public AdditionalFieldExpression(Type type, PrimaryKeyExpression backID, IntervalExpression?externalPeriod, PropertyRoute route) : base(DbExpressionType.AdditionalField, type) { this.BackID = backID; this.Route = route; this.ExternalPeriod = externalPeriod; }
public MListElementExpression(PrimaryKeyExpression rowId, EntityExpression parent, Expression?order, Expression element, IntervalExpression?systemPeriod, TableMList table, Alias alias) : base(DbExpressionType.MListElement, typeof(MListElement <,>).MakeGenericType(parent.Type, element.Type)) { this.RowId = rowId; this.Parent = parent; this.Order = order; this.Element = element; this.TablePeriod = systemPeriod; this.Table = table; this.Alias = alias; }
internal static Expression?Overlaps(this IntervalExpression?interval1, IntervalExpression?interval2) { if (interval1 == null) { return(null); } if (interval2 == null) { return(null); } if (interval1.PostgresRange != null) { return(new SqlFunctionExpression(typeof(bool), null, "&&", new Expression[] { interval1.PostgresRange !, interval2.PostgresRange ! }));
public ImplementedByAllExpression(Type type, Expression id, TypeImplementedByAllExpression typeId, IntervalExpression?externalPeriod) : base(DbExpressionType.ImplementedByAll, type) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (id.Type != typeof(string)) { throw new ArgumentException("string"); } this.Id = id; this.TypeId = typeId ?? throw new ArgumentNullException(nameof(typeId)); this.ExternalPeriod = externalPeriod; }
internal Expression GetProjectorExpression(Alias tableAlias, QueryBinder binder) { Schema.Current.AssertAllowed(this.BackReference.ReferenceTable.Type, inUserInterface: false); Type elementType = typeof(MListElement <,>).MakeGenericType(BackReference.FieldType, Field.FieldType); var rowId = RowIdExpression(tableAlias); IntervalExpression?period = GenerateSystemPeriod(tableAlias, binder); return(new MListElementExpression( rowId, (EntityExpression)this.BackReference.GetExpression(tableAlias, binder, null !, period), this.Order == null ? null : OrderExpression(tableAlias), this.Field.GetExpression(tableAlias, binder, rowId, period), period, this, tableAlias)); }
internal Expression FieldExpression(Alias tableAlias, QueryBinder binder, IntervalExpression?externalPeriod, bool withRowId) { var rowId = RowIdExpression(tableAlias); var exp = Field.GetExpression(tableAlias, binder, rowId, externalPeriod); if (!withRowId) { return(exp); } var type = this.Field.FieldType; var ci = typeof(MList <> .RowIdElement).MakeGenericType(type).GetConstructor(new[] { type, typeof(PrimaryKey), typeof(int?) }); var order = Order == null ? (Expression)Expression.Constant(null, typeof(int?)) : OrderExpression(tableAlias).Nullify(); return(Expression.New(ci, exp, rowId.UnNullify(), order)); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { var implementations = ImplementationColumns.SelectDictionary(t => t, (t, ic) => new EntityExpression(t, new PrimaryKeyExpression(new ColumnExpression(ic.Type.Nullify(), tableAlias, ic.Name)), period, null, null, null, null, AvoidExpandOnRetrieving)); var result = new ImplementedByExpression(IsLite ? Lite.Extract(FieldType) ! : FieldType, SplitStrategy, implementations); if (this.IsLite) { return(binder.MakeLite(result, null)); } else { return(result); } }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { var bindings = (from kvp in Fields let fi = kvp.Value.FieldInfo select new FieldBinding(fi, kvp.Value.Field.GetExpression(tableAlias, binder, id, period, entityContext))) .Concat(entityContext == null ? Enumerable.Empty <FieldBinding>() : Schema.Current.GetAdditionalQueryBindings(this.Route, entityContext, period)) .ToReadOnly(); return(new MixinEntityExpression(this.FieldType, bindings, tableAlias, this, entityContext)); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { var bindings = (from kvp in EmbeddedFields let fi = kvp.Value.FieldInfo select new FieldBinding(fi, kvp.Value.Field.GetExpression(tableAlias, binder, id, period, entityContext))) .Concat(entityContext == null ? Enumerable.Empty <FieldBinding>() : Schema.Current.GetAdditionalQueryBindings(this.Route, entityContext, period)) .ToReadOnly(); var mixins = this.Mixins?.Values.Select(m => (MixinEntityExpression)m.GetExpression(tableAlias, binder, id, period, entityContext)).ToReadOnly(); Expression hasValue = HasValue == null?SmartEqualizer.NotEqualNullable(id, id is PrimaryKeyExpression?QueryBinder.NullId(((PrimaryKeyExpression)id).ValueType) : (Expression)Expression.Constant(null, id.Type.Nullify())) : new ColumnExpression(((IColumn)HasValue).Type, tableAlias, HasValue.Name); return(new EmbeddedEntityExpression(this.FieldType, hasValue, bindings, mixins, this, null, entityContext)); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { return(new MListExpression(FieldType, (PrimaryKeyExpression)id, period, TableMList)); // keep back id empty for some seconds }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { return(Expression.Convert(new ColumnExpression(this.Type, tableAlias, Name), FieldType)); }
internal ReadOnlyCollection <MixinEntityExpression>?GenerateMixins(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?context) { if (this.Mixins == null) { return(null); } return(this.Mixins.Values.Select(m => (MixinEntityExpression)m.GetExpression(tableAlias, binder, id, period, context)).ToReadOnly()); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { return(new PrimaryKeyExpression(new ColumnExpression(this.Type.Nullify(), tableAlias, this.Name).Nullify())); }
internal abstract Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext);
internal IEnumerable <FieldBinding> GetAdditionalQueryBindings(PropertyRoute parent, EntityContextInfo entityContext, IntervalExpression?period) { //AssertAllowed(parent.RootType, inUserInterface: false); var ee = entityEvents.TryGetC(parent.RootType); if (ee == null || ee.AdditionalBindings == null) { return(Enumerable.Empty <FieldBinding>()); } return(ee.AdditionalBindings .Where(kvp => kvp.Key.Parent !.Equals(parent)) .Select(kvp => new FieldBinding(kvp.Key.FieldInfo !, new AdditionalFieldExpression(kvp.Key.FieldInfo !.FieldType, entityContext.EntityId, entityContext.MListRowId, period, kvp.Key))) .ToList()); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period) { var bindings = (from kvp in Fields let fi = kvp.Value.FieldInfo select new FieldBinding(fi, kvp.Value.Field.GetExpression(tableAlias, binder, id, period))) .Concat(Schema.Current.GetAdditionalQueryBindings(this.Route, (PrimaryKeyExpression)id, period)) .ToReadOnly(); return(new MixinEntityExpression(this.FieldType, bindings, tableAlias, this)); }
internal abstract Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period);
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { Expression result = new ImplementedByAllExpression( IsLite ? Lite.Extract(FieldType) ! : FieldType, new ColumnExpression(Column.Type, tableAlias, Column.Name), new TypeImplementedByAllExpression(new PrimaryKeyExpression(new ColumnExpression(ColumnType.Type.Nullify(), tableAlias, ColumnType.Name))), period); if (this.IsLite) { return(binder.MakeLite(result, null)); } else { return(result); } }
internal ReadOnlyCollection <FieldBinding> GenerateBindings(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { List <FieldBinding> result = new List <FieldBinding> { new FieldBinding(Table.fiId, id) }; foreach (var ef in this.Fields.Values) { var fi = ef.FieldInfo; if (!ReflectionTools.FieldEquals(fi, fiId)) { result.Add(new FieldBinding(fi, ef.Field.GetExpression(tableAlias, binder, id, period, entityContext))); } } if (this.Type.IsEntity() && entityContext != null) { result.AddRange(Schema.Current.GetAdditionalQueryBindings(PropertyRoute.Root(this.Type), entityContext, period)); } return(result.ToReadOnly()); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { if (this.Type == this.FieldType) { return(new ColumnExpression(this.Type, tableAlias, this.Name)); } if (this.Type == typeof(DateTime)) { return(Expression.Property(new ColumnExpression(this.Type, tableAlias, this.Name), piDateTimeTicks)); } throw new NotImplementedException("FieldTicks of type {0} not supported".FormatWith(this.Type)); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { var column = new ColumnExpression(this.Type, tableAlias, this.Name); if (this.Type == this.FieldType) { return(column); } return(Expression.Convert(column, this.FieldType)); }
internal override Expression GetExpression(Alias tableAlias, QueryBinder binder, Expression id, IntervalExpression?period, EntityContextInfo?entityContext) { Type cleanType = IsLite ? Lite.Extract(FieldType) ! : FieldType; var result = new EntityExpression(cleanType, new PrimaryKeyExpression(new ColumnExpression(this.Type.Nullify(), tableAlias, Name)), period, null, null, null, null, AvoidExpandOnRetrieving); if (this.IsLite) { return(binder.MakeLite(result, null)); } else { return(result); } }