public string ToSqlText(DataParameterCollection dpc, Dialect.DbDialect dd) { return(string.Format("{0}.{1} {4} {2}.{3}", dd.QuoteForTableName(Table1), dd.QuoteForColumnName(Key1), dd.QuoteForTableName(Table2), dd.QuoteForColumnName(Key2), StringHelper.EnumToString(Comp))); }
//internal FromClause(params string[] linkColumnNames) //{ // if (linkColumnNames.Length < 2 || linkColumnNames.Length % 2 != 0) // { // throw new ArgumentException("LinkColumnNames.Length not even or less than 2."); // } // joinClauseList = new JoinClause[linkColumnNames.Length / 2]; // for (int i = 0; i < linkColumnNames.Length; i+=2) // { // joinClauseList[i / 2] = new JoinClause(linkColumnNames[i], linkColumnNames[i + 1], // CompareOpration.Equal, JoinMode.Inner); // } //} public string ToSqlText(DataParameterCollection dpc, Dialect.DbDialect dd, bool isView) { if (!MainViewName.IsNullOrEmpty() && isView) { return(dd.QuoteForTableName(MainViewName)); } if (MainTableName != null) { return(dd.QuoteForTableName(MainTableName)); } if (_fromStrings.Contains(dd)) { return((string)_fromStrings[dd]); } string ret; if (PartOf != null) { ret = dd.QuoteForLimitTableName(ModelContext.GetInstance(PartOf).Info.From.MainTableName); } else { var sd = new StringDictionary(); ret = dd.QuoteForTableName(JoinClauseList[0].Table1); sd.Add(ret, ""); for (int i = 0; i < JoinClauseList.Length; i++) { if (i != 0 && dd.NeedBracketForJoin) { ret = string.Format("({0})", ret); } string tn = dd.QuoteForTableName(JoinClauseList[i].Table2); if (sd.ContainsKey(tn)) { tn = dd.QuoteForTableName(JoinClauseList[i].Table1); } sd.Add(tn, ""); ret = string.Format("{0} {3} JOIN {1} ON {2}", ret, tn, JoinClauseList[i].ToSqlText(dpc, dd, isView), JoinClauseList[i].Mode); } } lock (_fromStrings.SyncRoot) { _fromStrings[dd] = ret; } return(ret); }