protected internal override Expression VisitLiteReference(LiteReferenceExpression lite) { var reference = Visit(lite.Reference); var toStr = Visit(lite.CustomToStr); return(Lite.ToLiteFatInternalExpression(reference, toStr ?? Expression.Constant(null, typeof(string)))); }
protected override Expression VisitLiteReference(LiteReferenceExpression lite) { var id = binder.GetId(lite.Reference); var typeId = binder.GetEntityType(lite.Reference); var toStr = LiteToString(lite, typeId); return new LiteValueExpression(lite.Type, typeId, id, toStr); }
protected internal override Expression VisitLiteReference(LiteReferenceExpression lite) { var oldInLite = inLite; inLite = true; var result = base.VisitLiteReference(lite); inLite = oldInLite; return(result); }
internal static Expression EntityIn(LiteReferenceExpression liteReference, IEnumerable <Lite <IEntity> > collection) { if (collection.IsEmpty()) { return(False); } Dictionary <Type, PrimaryKey[]> entityIDs = collection.Where(a => a.IdOrNull.HasValue).AgGroupToDictionary(a => a.EntityType, gr => gr.Select(a => a.Id).ToArray()); return(EntityIn(liteReference.Reference, entityIDs)); }
protected internal virtual Expression VisitLiteReference(LiteReferenceExpression lite) { var newRef = Visit(lite.Reference); var newToStr = Visit(lite.CustomToStr); if (newRef != lite.Reference || newToStr != lite.CustomToStr) { return(new LiteReferenceExpression(lite.Type, newRef, newToStr, lite.LazyToStr, lite.EagerEntity)); } return(lite); }
protected internal override Expression VisitLiteReference(LiteReferenceExpression lite) { var id = lite.Reference is ImplementedByAllExpression || lite.Reference is ImplementedByExpression && ((ImplementedByExpression)lite.Reference).Implementations.Select(imp => imp.Value.ExternalId.ValueType.Nullify()).Distinct().Count() > 1 ? (Expression)binder.GetIdString(lite.Reference) : (Expression)binder.GetId(lite.Reference); var typeId = binder.GetEntityType(lite.Reference); var toStr = LiteToString(lite, typeId); return(new LiteValueExpression(lite.Type, typeId, id, toStr)); }
protected internal override Expression VisitLiteReference(LiteReferenceExpression lite) { var id = lite.Reference is ImplementedByAllExpression || lite.Reference is ImplementedByExpression && ((ImplementedByExpression)lite.Reference).Implementations.Select(imp=>imp.Value.ExternalId.ValueType.Nullify()).Distinct().Count() > 1 ? (Expression)binder.GetIdString(lite.Reference) : (Expression)binder.GetId(lite.Reference); var typeId = binder.GetEntityType(lite.Reference); var toStr = LiteToString(lite, typeId); return new LiteValueExpression(lite.Type, typeId, id, toStr); }
private Expression?LiteToString(LiteReferenceExpression lite, Expression typeId) { if (lite.CustomToStr != null) { return(Visit(lite.CustomToStr)); } if (lite.Reference is ImplementedByAllExpression) { return(null); } if (lite.LazyToStr) { return(null); } if (IsCacheable(typeId)) { return(null); } if (lite.Reference is EntityExpression entityExp) { if (entityExp.AvoidExpandOnRetrieving) { return(null); } return(binder.BindMethodCall(Expression.Call(entityExp, EntityExpression.ToStringMethod))); } if (lite.Reference is ImplementedByExpression ibe) { if (ibe.Implementations.Any(imp => imp.Value.AvoidExpandOnRetrieving)) { return(null); } return(ibe.Implementations.Values.Select(ee => new When(SmartEqualizer.NotEqualNullable(ee.ExternalId, QueryBinder.NullId(ee.ExternalId.ValueType)), binder.BindMethodCall(Expression.Call(ee, EntityExpression.ToStringMethod))) ).ToCondition(typeof(string))); } return(binder.BindMethodCall(Expression.Call(lite.Reference, EntityExpression.ToStringMethod))); }
protected internal override Expression VisitLiteReference(LiteReferenceExpression lite) { if (lite.EagerEntity) { return(base.VisitLiteReference(lite)); } var id = lite.Reference is ImplementedByAllExpression || lite.Reference is ImplementedByExpression && ((ImplementedByExpression)lite.Reference).Implementations.Select(imp => imp.Value.ExternalId.ValueType.Nullify()).Distinct().Count() > 1 ? (Expression)binder.GetIdString(lite.Reference) : (Expression)binder.GetId(lite.Reference); var typeId = binder.GetEntityType(lite.Reference); var toStr = LiteToString(lite, typeId); //var toStr2 = Visit(toStr); //AdditionalBinding in embedded requires it, but makes problems in many other lites in Nominator return(new LiteValueExpression(lite.Type, typeId, id, toStr)); }
private Expression LiteToString(LiteReferenceExpression lite, Expression typeId) { if (lite.CustomToStr != null) return Visit(lite.CustomToStr); if (lite.Reference is ImplementedByAllExpression) return null; if (IsCacheable(typeId)) return null; if (lite.Reference is EntityExpression) { var ee = (EntityExpression)lite.Reference; if(ee.AvoidExpandOnRetrieving) return null; return binder.BindMethodCall(Expression.Call(lite.Reference, EntityExpression.ToStringMethod)); } if(lite.Reference is ImplementedByExpression) { var ibe = (ImplementedByExpression)lite.Reference; if(ibe.Implementations.Any(imp => imp.Value.AvoidExpandOnRetrieving)) return null; return ibe.Implementations.Values.Select(ee => new When(SmartEqualizer.NotEqualNullable(ee.ExternalId, QueryBinder.NullId), binder.BindMethodCall(Expression.Call(ee, EntityExpression.ToStringMethod))) ).ToCondition(typeof(string)); } return binder.BindMethodCall(Expression.Call(lite.Reference, EntityExpression.ToStringMethod)); }
protected internal override Expression VisitLiteReference(LiteReferenceExpression lite) { return(base.VisitLiteReference(lite)); }
protected virtual bool CompareLiteReference(LiteReferenceExpression a, LiteReferenceExpression b) { return(Compare(a.Reference, b.Reference) && Compare(a.CustomToStr, b.CustomToStr)); }
internal static Expression EntityIn(LiteReferenceExpression liteReference, IEnumerable<Lite<IEntity>> collection) { if (collection.IsEmpty()) return False; Dictionary<Type, PrimaryKey[]> entityIDs = collection.Where(a => a.IdOrNull.HasValue).AgGroupToDictionary(a => a.EntityType, gr => gr.Select(a => a.Id).ToArray()); return EntityIn(liteReference.Reference, entityIDs); }
protected virtual Expression VisitLiteReference(LiteReferenceExpression lite) { var newRef = Visit(lite.Reference); var newToStr = Visit(lite.CustomToStr); if (newRef != lite.Reference || newToStr != lite.CustomToStr) return new LiteReferenceExpression(lite.Type, newRef, newToStr); return lite; }
internal static Expression EntityIn(LiteReferenceExpression liteReference, IEnumerable<Lite<IIdentifiable>> collection) { if (collection.IsEmpty()) return False; Dictionary<Type, object[]> entityIDs = collection.AgGroupToDictionary(a => a.EntityType, gr => gr.Select(a => (object)(a.IdOrNull ?? int.MaxValue)).ToArray()); return EntityIn(liteReference.Reference, entityIDs); }
protected override Expression VisitLiteReference(LiteReferenceExpression lite) { return base.VisitLiteReference(lite); }