public override Node VisitQueryProject(QueryProject project) { project.Source = this.VisitExpression(project.Source); Composer save = this.contextComposer; Composer c = this.contextComposer = this.GetComposer(project.Source); bool savehcr = this.hasContextReference; this.hasContextReference = false; this.VisitExpressionList(project.ProjectionList); this.hasContextReference = savehcr; this.contextComposer = save; return(this.Compose(project, c)); }
private static void OperParaProName(int existCount, ParaEntity para, DependencyObject sub, IMetadataContainer mc, IQueryProjectContainer srv) { string name = para.Name; string extendFix = string.Empty; if (existCount > 0) { extendFix = "X" + (existCount + 1); //后续以X+流水 name = name + extendFix; } int index = name.IndexOf("."); if (index > -1) { para.PropertyName = name.Replace('.', '_'); //带上表明前缀 以防止有相同的属性名参数但是表明不一样(a.Status,b.Status),导致后续跟进参数注册属性会报错,不能注册相同的参数 } else { //可能存在查询单一表情况,不带别名的 para.PropertyName = name; } para.SecondPropertyName = para.PropertyName + "2"; if (para.ControlType == ControlTypeEnum.PickList) { para.PickListTypeName = sub["CONTROL_CODE"].ToStringExtension(); if (para.PickListTypeName != string.Empty) { var pick = mc.GetPickListTypeElement(para.PickListTypeName); if (pick != null) { //para.Tip = pick.DisplayName; //20170829 mark by shenbao for P001-170829002 LocalizableString localStr = new LocalizableString(pick.DisplayName); //20170829 add by shenbao for P001-170829002 para.Tip = localStr[System.Globalization.CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName]; //20170829 add by shenbao for P001-170829002 } } } else if (para.ControlType == ControlTypeEnum.SelectControl) { para.QueryProjectId = sub["CONTROL_CODE"].ToStringExtension(); QueryProject qp = srv.QueryProjects.FirstOrDefault(c => c.Id == para.QueryProjectId) as QueryProject; string idColumn = string.Empty; if (qp != null) { idColumn = qp.ContextDataColumn; para.Tip = qp.DisplayName; } else { idColumn = "KEY_FIELD_ID"; //理论上永远不会走到这里,除非FINCTION_INFO没有配置开窗编号,或者这个编号是错误的 } para.TargetEntityPirmaryKeyID = idColumn; if (index >= 0) { para.PropertyName = name.Substring(0, index) + "_" + idColumn + extendFix; //如果是开窗类型,则需要重新设置PropertyName,为ID字段 } else { para.PropertyName = idColumn + extendFix; } para.SecondPropertyName = para.PropertyName + "2"; } }
public virtual Node VisitQueryProject(QueryProject project, QueryProject changes, QueryProject deletions, QueryProject insertions){ this.UpdateSourceContext(project, changes); if (project == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return project; }
public virtual Differences VisitQueryProject(QueryProject project1, QueryProject project2){ Differences differences = new Differences(project1, project2); if (project1 == null || project2 == null){ if (project1 != project2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } QueryProject changes = (QueryProject)project2.Clone(); QueryProject deletions = (QueryProject)project2.Clone(); QueryProject insertions = (QueryProject)project2.Clone(); // project1.Context; // project1.Members; // project1.ProjectedType; // project1.ProjectionList; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public virtual Node VisitQueryProject(QueryProject project){ if (project == null) return null; project.Source = this.VisitExpression(project.Source); project.ProjectionList = this.VisitExpressionList(project.ProjectionList); return project; }
public override Node VisitQueryProject(QueryProject qp) { if (qp == null) return null; Class cc = this.currentMethod.Scope.ClosureClass; qp.Source = this.VisitExpression(qp.Source); if (qp.Source == null || qp.Source.Type == null) return null; Cardinality card = this.typeSystem.GetCardinality(qp.Source, this.TypeViewer); if (card != Cardinality.OneOrMore && card != Cardinality.ZeroOrMore) { this.HandleError(qp.Source, Error.QueryNotStream); return null; } if (qp.ProjectionList == null || qp.ProjectionList.Count == 0) { this.HandleError(qp.Source, Error.QueryBadProjectionList); } for (int i = 0, n = qp.ProjectionList.Count; i < n; i++) { Expression x = this.VisitExpression(qp.ProjectionList[i]); if (x == null || x.Type == null) return null; qp.ProjectionList[i] = x; } if (qp.Type == null || qp.ProjectedType == null) return null; return qp; }
public override Node VisitQueryProject(QueryProject project){ if (project == null) return null; project.Source = this.VisitExpression(project.Source); if (project.Source == null || project.Source.Type == null) return project; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(project.Source, this.TypeViewer); project.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); ExpressionList list = new ExpressionList(); for (int i=0; i < project.ProjectionList.Count; i++){ QueryAxis axis = project.ProjectionList[i] as QueryAxis; if (axis != null && axis.Name == Identifier.Empty){ axis.Source = this.VisitExpression(axis.Source); this.ResolveAxis(axis); this.GetProjectionList(axis.AccessPlan, axis.Source, list); } else{ list.Add(this.VisitExpression(project.ProjectionList[i])); } } project.ProjectionList = list; this.contextScope = this.contextScope.Previous; if (project.ProjectedType == null){ int len = project.ProjectionList.Count; if (len == 1 && this.GetExpressionName(project.ProjectionList[0]) == null){ Expression x = project.ProjectionList[0]; if (x != null && x.Type != null) project.ProjectedType = x.Type; } else{ FieldList fields = new FieldList(); for( int i = 0, cn = 0; i < len; i++ ){ Expression x = project.ProjectionList[i]; if (x != null && x.Type != null){ Identifier name = this.GetExpressionName(x); Field f = new Field(null, new AttributeList(1), FieldFlags.Public, name, x.Type, null); if (name == null || name == Identifier.Empty){ f.Name = Identifier.For("Item"+cn); cn++; f.Attributes.Add(new AttributeNode(new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor()), null)); } fields.Add(f); } } if (fields.Count == len){ project.ProjectedType = TupleType.For(fields, this.currentType); project.Members = this.typeSystem.GetDataMembers(project.ProjectedType); } } } if (project.ProjectedType != null){ project.Type = this.GetResultType(project.Source, project.ProjectedType, Cardinality.One); } return project; }
public virtual void VisitQueryProject(QueryProject project){ if (project == null) return; this.VisitExpression(project.Source); this.VisitExpressionList(project.ProjectionList); }
public override Node VisitQueryProject(QueryProject project){ if (project == null) return null; return base.VisitQueryProject((QueryProject)project.Clone()); }
public virtual Node VisitQueryProject(QueryProject project1, QueryProject project2){ if (project1 == null) return null; if (project2 == null){ project1.Source = this.VisitExpression(project1.Source, null); project1.ProjectionList = this.VisitExpressionList(project1.ProjectionList, null); }else{ project1.Source = this.VisitExpression(project1.Source, project2.Source); project1.ProjectionList = this.VisitExpressionList(project1.ProjectionList, project2.ProjectionList); } return project1; }
public override Node VisitQueryProject(QueryProject qp) { // generate translation code Block block = null; Node closure = this.StartQueryClosure(qp.ProjectedType, "select", out block); BlockScope scope = block.Scope; Expression feTarget = null; Block feBody = null; block.Statements.Add(this.BuildClosureForEach(qp.Source, ref feTarget, out feBody, scope)); Block inner = new Block(new StatementList(qp.ProjectionList.Count + 1)); feBody.Statements.Add(this.IfNotNull(feTarget, inner)); Expression projectedTarget = this.NewClosureLocal(qp.ProjectedType, scope); qp.Context.Target = feTarget; if( qp.ProjectionList.Count == 1 && projectedTarget.Type.UniqueKey == qp.ProjectionList[0].Type.UniqueKey ) { // case of scalar projection Expression x = qp.ProjectionList[0]; inner.Statements.Add(new AssignmentStatement(projectedTarget, x)); } else if( qp.ProjectionList.Count > 0 ) { // create projected instance if (!qp.ProjectedType.IsValueType) { Construct cons = new Construct(); cons.Constructor = new MemberBinding(null, this.GetTypeView(qp.ProjectedType).GetConstructor()); cons.Type = qp.ProjectedType; inner.Statements.Add(new AssignmentStatement(projectedTarget, cons)); } // non-scalar projection Debug.Assert( qp.Members != null && qp.Members.Count == qp.ProjectionList.Count, "Projection length mismatch" ); for( int i = 0, n = qp.Members.Count; i < n; i++ ) { Member m = qp.Members[i]; TypeNode mtype = this.typeSystem.GetMemberType(m); MemberBinding mb = new MemberBinding(projectedTarget, m); mb.Type = mtype; Expression x = qp.ProjectionList[i]; inner.Statements.Add(new AssignmentStatement(mb, this.typeSystem.ImplicitCoercion(x, mtype, this.TypeViewer))); } } inner.Statements.Add(new Yield(projectedTarget)); // normalize return this.EndQueryClosure(closure, qp.Type); }
public override Node VisitQueryProject( QueryProject qp ){ if (qp == null) return null; qp.Source = this.VisitExpression(qp.Source); QueryGroupBy save = this.currentGroup; this.currentGroup = this.GetGroupBySource(qp.Source); if (this.currentGroup == null){ this.currentGroup = new QueryGroupBy(); } this.VisitExpressionList(qp.ProjectionList); if (this.currentGroup.Source == null && this.currentGroup.AggregateList.Count > 0){ qp.Source = this.InjectGroupBy(qp.Source, this.currentGroup); } this.currentGroup = save; if (qp.ProjectedType != null){ qp.ProjectedType = this.VisitTypeReference(qp.ProjectedType); } return qp; }
public override Node VisitQueryProject(QueryProject project) { project.Source = this.VisitExpression(project.Source); Composer save = this.contextComposer; Composer c = this.contextComposer = this.GetComposer(project.Source); bool savehcr = this.hasContextReference; this.hasContextReference = false; this.VisitExpressionList(project.ProjectionList); this.hasContextReference = savehcr; this.contextComposer = save; return this.Compose(project, c); }
public EventingVisitor(Action<QueryProject> visitQueryProject) { VisitedQueryProject += visitQueryProject; } public event Action<QueryProject> VisitedQueryProject; public override Node VisitQueryProject(QueryProject project) { if (VisitedQueryProject != null) VisitedQueryProject(project); return base.VisitQueryProject(project); }