private void AppendField( SqlUtils.NavigationStep step, MetadataProperty prop, StringBuilder sb) { sb.AppendFormat("[{0}].[{1}]", step != null ? (object)step.TargetAlias : (object)this.Alias, (object)prop.DataField); }
public ExternalAssociationNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataAssociationRef externalAssociationRef) : base(navigation, predecessor, path) { this.ExternalAssociationRef = externalAssociationRef; }
public ChildNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataChildRef childRef) : base(navigation, predecessor, path) { this.ChildRef = childRef; }
public AssociationNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataAssociationRef associationRef) : base(navigation, predecessor, path) { this.AssociationRef = associationRef; }
protected NavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path) { this.Owner = navigation; this.Predecessor = predecessor; this.Path = path; }
public SqlUtils.NavigationStep EnsureRootStep(string path) { SqlUtils.NavigationStep navigationStep1 = !string.IsNullOrEmpty(path) ? this.FindRootStep(path) : throw new ArgumentNullException(nameof(path)); if (navigationStep1 != null) { return(navigationStep1); } string predecessorPath; string identifier; MetadataClass refClass1; bool isExternalRef; SqlUtils.Navigation.ParseLastPartOfPath(this.Class.Metadata.Classes, path, out predecessorPath, out identifier, out refClass1, out isExternalRef); SqlUtils.NavigationStep predecessor = !string.IsNullOrEmpty(predecessorPath) ? this.EnsureRootStep(predecessorPath) : (SqlUtils.NavigationStep)null; MetadataClass refClass2 = predecessor != null ? predecessor.TargetClass : this.Class; SqlUtils.NavigationStep navigationStep2; if (isExternalRef) { MetadataProperty metadataProperty = refClass1.Properties.Need(identifier); if (!metadataProperty.IsLink) { throw new Exception(string.Format("Свойство \"{0}.{1}\" не является отношением.", (object)refClass1.Name, (object)identifier)); } navigationStep2 = (SqlUtils.NavigationStep) new SqlUtils.ExternalAssociationNavigationStep(this, predecessor, path, metadataProperty.Association.Refs.Need(refClass2)); } else { MetadataProperty property; MetadataChildRef childRef; refClass2.NeedMember(identifier, out property, out childRef); if (property != null) { if (!property.IsLink) { throw new DataException(string.Format("\"{0}\" не является ассоциацией или дочерним объектом.", (object)identifier)); } MetadataAssociationRefList refs = property.Association.Refs; if (refClass1 == null && refs.Count != 1) { throw new DataException(string.Format("\"{0}\" является ассоциацией с вариантами связи. В тексте запроса такое поле следует указывать в форме \"имя-свойства:имя-связанного-класса\" (например, \"Subject:Person\").", (object)identifier)); } navigationStep2 = (SqlUtils.NavigationStep) new SqlUtils.AssociationNavigationStep(this, predecessor, path, refClass1 == null ? refs[0] : refs.Need(refClass1)); } else { navigationStep2 = (SqlUtils.NavigationStep) new SqlUtils.ChildNavigationStep(this, predecessor, path, childRef); } } navigationStep2.TargetAlias = this.CreateUniqueAlias(navigationStep2.TargetClass.DataTable); this.RootSteps.Add(navigationStep2); return(navigationStep2); }
private SqlUtils.NavigationStep FindRootStep(string path) { for (int index = 0; index < this.RootSteps.Count; ++index) { SqlUtils.NavigationStep rootStep = this.RootSteps[index]; if (string.Compare(rootStep.Path, path, true) == 0) { return(rootStep); } } return((SqlUtils.NavigationStep)null); }
public void RegisterIdentifier( string ident, out SqlUtils.NavigationStep step, out MetadataProperty prop) { int length = ident.LastIndexOf('.'); string name; if (length >= 0) { step = this.EnsureRootStep(ident.Substring(0, length)); name = ident.Substring(length + 1); } else { step = (SqlUtils.NavigationStep)null; name = ident; } MetadataClass metadataClass = step != null ? step.TargetClass : this.Class; prop = metadataClass.Properties.Find(name); }