示例#1
0
 public abstract string CreateMultipleTableFromTableSelectStatement(MultipleTable table);
示例#2
0
 public abstract string[] CreateMultipleTableColumns(MultipleTable table);
示例#3
0
        /// <summary>
        /// �õ�����ѯ�е�From��ı����
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public string CreateMultipleTableFromTableSelectStatement(MultipleTable table)
        {
            StringBuilder sql = new StringBuilder(500);

            sql.Append(BuildColumnName(table.BeginWithTable));

            string nextTableName = BuildColumnName(table.BeginWithTable);

            int num = 0;

            for (int j = 0; j < table.RelationDefs.Count; j++)
            {
                RelationDef def = table.RelationDefs[j];

                sql.Append(" " + def.JoinType + " ");
                sql.Append(" " + BuildColumnName(def.SourceTableName) + "");
                if (def.SourceTableName != def.SourceTableAlias)
                    sql.Append(AliasKey + BuildColumnName(def.SourceTableAlias) + " ");

                nextTableName = def.SourceTableName;

                if (def.RelationDetails.Count > 0)
                {
                    sql.Append(" ON ");
                    for (int k = 0; k < def.RelationDetails.Count; k++)
                    {
                        RelationDetail detail = def.RelationDetails[k] as RelationDetail;
                        sql.Append("" + BuildColumnName(def.TabelAlias) + "." + BuildColumnName(detail.FieldName) + " ");
                        sql.Append(TypeHelper.CompareOptionToString(detail.Compare));
                        sql.Append(" " + BuildColumnName(def.SourceTableAlias) + "." + BuildColumnName(detail.SourceFieldName) + "");
                        sql.Append(" AND ");
                    }
                    sql.Remove(sql.Length - 5, 5);
                }

                num++;
            }

            return sql.ToString();
        }
示例#4
0
        /// <summary>
        /// �õ�����ѯ�еIJ�ѯ��������
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public string CreateMultipleTableFromColumnSelectStatement(MultipleTable table)
        {
            StringBuilder sql = new StringBuilder();

            int i = 0;
            foreach (Column col in table.Columns)
            {
                if (i > 0)
                    sql.Append(",");

                if (string.IsNullOrEmpty(col.NameAlias))
                    sql.Append(BuildColumnName(col.TableName) + "." + BuildColumnName(col.Name));
                else
                    sql.Append(BuildColumnName(col.TableName) + "." + BuildColumnName(col.Name) + " as " + BuildColumnName(col.NameAlias));

                i++;
            }

            return sql.ToString();
        }
示例#5
0
        ///// <summary>
        ///// �õ�������е�From��ı����
        ///// </summary>
        ///// <param name="table"></param>
        ///// <returns></returns>
        //public string CreateEntityRelationTableFromTableSelectStatement(EntityRelationTable table)
        //{
        //    StringBuilder sql = new StringBuilder(500);
        //    sql.Append(BuildColumnName(table.BeginTableName));
        //    string nextTableName = BuildColumnName(table.BeginTableName);
        //    int num = 0;
        //    for (int j = 0; j < table.RelationDefs.Count; j++)
        //    {
        //        RelationDef def = table.RelationDefs[j] as RelationDef;
        //        sql.Append(" " + def.JoinType + " ");
        //        sql.Append(" " + BuildColumnName(def.SourceTableName) + "");
        //        if (def.SourceTableName != def.SourceTableAlias)
        //            sql.Append(" AS " + BuildColumnName(def.SourceTableAlias) + " ");
        //        nextTableName = def.SourceTableName;
        //        if (def.RelationDetails.Count > 0)
        //        {
        //            sql.Append(" ON ");
        //            for (int k = 0; k < def.RelationDetails.Count; k++)
        //            {
        //                RelationDetail detail = def.RelationDetails[k] as RelationDetail;
        //                sql.Append("" + BuildColumnName(def.TabelAlias) + "." + BuildColumnName(detail.FieldName) + " ");
        //                sql.Append(TypeHelper.CompareOptionToString(detail.Compare));
        //                sql.Append(" " + BuildColumnName(def.SourceTableAlias) + "." + BuildColumnName(detail.SourceFieldName) + "");
        //                sql.Append(" AND ");
        //            }
        //            sql.Remove(sql.Length - 5, 5);
        //        }
        //        num++;
        //    }
        //    return sql.ToString();
        //}
        /// <summary>
        /// �õ�����ѯ�еIJ�ѯ��������
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public string[] CreateMultipleTableColumns(MultipleTable table)
        {
            List<string> columns = new List<string>();
            foreach (Column col in table.Columns)
            {
                string strCol = "";

                if (string.IsNullOrEmpty(col.NameAlias))
                    strCol = BuildColumnName(col.TableName) + "." + BuildColumnName(col.Name);
                else
                    strCol = BuildColumnName(col.TableName) + "." + BuildColumnName(col.Name) + " as " + BuildColumnName(col.NameAlias);

                columns.Add(strCol);
            }

            return columns.ToArray();
        }
示例#6
0
 private void AddMultipleClass(Type type)
 {
     lock (syncObj)
     {
         MultipleTable t = new MultipleTable(type);
         if (!dictMultipleType.ContainsKey(t.Name))
         {
             dictMultipleType.Add(t.Name, type);
             dictMultipleTable.Add(type, t);
         }
     }
 }