public override ISqlElement VisitIsReference(IsReferenceExpression expression) { var result = base.VisitIsReference(expression); var tableMapping = mappingSource.ResolveTableOrNull(expression.ObjectName); if (tableMapping == null) { const string messageFormat = "operator [Ссылка] has unknown object name [{0}]"; throw new InvalidOperationException(string.Format(messageFormat, expression.ObjectName)); } return(result); }
public override ISqlElement VisitIsReference(IsReferenceExpression expression) { var queryRoot = queryEntityRegistry.Get(expression.Argument.Table); var propertyNames = expression.Argument.Name.Split('.'); var propertiesEnumerator = new PropertiesEnumerator(propertyNames, queryRoot, queryEntityAccessor); var referencedProperties = propertiesEnumerator.Enumerate(); if (referencedProperties.Count != 1) { const string messageFormat = "operator IsReference property [{0}] has many " + "variants which is not supported currently"; throw new InvalidOperationException(string.Format(messageFormat, expression.Argument.Name)); } var property = referencedProperties[0]; var entity = property.nestedEntities.SingleOrDefault(x => x.mapping.QueryTableName == expression.ObjectName); if (entity == null) { const string messageFormat = "can't find entity [{0}] for property [{1}]"; throw new InvalidOperationException(string.Format(messageFormat, expression.ObjectName, expression.Argument.Name)); } var unionCondition = queryEntityAccessor.GetUnionCondition(property, entity); if (unionCondition == null) { const string messageFormat = "property [{0}] has only one possible type"; throw new InvalidOperationException(string.Format(messageFormat, expression.Argument.Name)); } if (queryRoot.additionalFields == null) { queryRoot.additionalFields = new List <SelectFieldExpression>(); } var filterColumnName = nameGenerator.GenerateColumnName(); queryRoot.additionalFields.Add(new SelectFieldExpression { Expression = unionCondition, Alias = filterColumnName }); var result = new ColumnReferenceExpression { Name = filterColumnName, Table = expression.Argument.Table }; rewritten.Add(result); return(result); }
public virtual ISqlElement VisitIsReference(IsReferenceExpression expression) { expression.Argument = (ColumnReferenceExpression)VisitColumnReference(expression.Argument); return(expression); }
public override ISqlElement VisitIsReference(IsReferenceExpression expression) { NotSupported(expression, expression.Argument, expression.ObjectName); return(expression); }