internal bool ExecuteQuery() { try { if (!QueryAnalyze()) { return(false); } //got if (this.selectedRelations.Count == 2) // có 2 rel { if (flagNaturalJoin != true) //xe truong hop { this.selectedRelations[0] = Descartes(); } else { this.selectedRelations[0] = NaturalJoin(); } } else { foreach (ProbAttribute attr in this.selectedRelations[0].Scheme.Attributes) { if (!attr.AttributeName.Contains(".")) { attr.AttributeName = String.Format("{0}.{1}", this.selectedRelations[0].RelationName, attr.AttributeName); } } } if (!this.queryString.Contains("where")) //query ko co where { this.relationResult = getRelationBySelectAttribute(this.selectedRelations[0], this.selectedAttributes); // lay danh sach att return(true); } else { SelectCondition Condition = new SelectCondition(this.selectedRelations[0], this.conditionString); if (!Condition.CheckConditionString()) { this.MessageError = Condition.MessageError; return(false); } foreach (ProbTuple tuple in this.selectedRelations[0].tuples) { if (Condition.Satisfied(tuple)) { this.relationResult.tuples.Add(tuple); } } if (Condition.MessageError != string.Empty) { this.MessageError = Condition.MessageError; return(false); } if (Condition.conditionString == string.Empty) { this.MessageError = Condition.MessageError; return(false); } this.relationResult.Scheme = this.selectedRelations[0].Scheme; this.relationResult = getRelationBySelectAttribute(this.relationResult, this.selectedAttributes); } } catch { return(false); } return(true); }
internal bool ExcuteQuery() { try { if (!QueryAnalyze()) { return(false); } if (this.selectedRelations.Count == 1) { foreach (ProbAttribute attr in this.selectedRelations[0].Scheme.Attributes) { if (!attr.AttributeName.Contains(".")) { attr.AttributeName = String.Format("{0}.{1}", this.selectedRelations[0].RelationName, attr.AttributeName); } } } else { if (flagNaturalJoin != true) { var relationRes = this.selectedRelations[0]; for (int i = 1; i < this.selectedRelations.Count(); i++) { relationRes = Descartes(relationRes, this.selectedRelations[i]); } this.selectedRelations[0] = relationRes; } else { var relationRes = this.selectedRelations[0]; for (int i = 1; i < this.selectedRelations.Count(); i++) { relationRes = NaturalJoin(relationRes, this.selectedRelations[i], this.OperationNaturalJoin[i - 1]); } this.selectedRelations[0] = relationRes; } } if (!this.queryString.Contains(Common.Where)) { this.relationResult = getRelationBySelectAttributeV2(this.selectedRelations[0], this.selectedAttributes); return(true); } else { SelectCondition Condition = new SelectCondition(this.selectedRelations[0], this.conditionString); Condition.ProcessConditionString(); if (!string.IsNullOrEmpty(Condition.MessageError)) { MessageError = Condition.MessageError; return(false); } foreach (ProbTuple tuple in this.selectedRelations[0].tuples) { if (Condition.Satisfied(tuple)) { this.relationResult.tuples.Add(tuple); } else { if (!string.IsNullOrEmpty(Condition.MessageError)) { MessageError = Condition.MessageError; return(false); } } } if (Condition.MessageError != string.Empty) { this.MessageError = Condition.MessageError; return(false); } if (Condition.conditionString == string.Empty) { this.MessageError = Condition.MessageError; return(false); } this.relationResult.Scheme = this.selectedRelations[0].Scheme; this.relationResult = getRelationBySelectAttribute(this.relationResult, this.selectedAttributes); } } catch { return(false); } return(true); }