示例#1
0
        /// <summary>
        /// 返回一个Query节
        /// </summary>
        /// <returns></returns>
        public QuerySection From(QueryCreator creator)
        {
            if (creator.Table == null)
            {
                throw new DataException("用创建器操作时,表不能为null!");
            }

            FromSection <ViewEntity> f = this.From <ViewEntity>(creator.Table);

            if (creator.IsRelation)
            {
                foreach (TableJoin join in creator.Relations.Values)
                {
                    if (join.Type == JoinType.LeftJoin)
                    {
                        f.LeftJoin <ViewEntity>(join.Table, join.Where);
                    }
                    else if (join.Type == JoinType.RightJoin)
                    {
                        f.RightJoin <ViewEntity>(join.Table, join.Where);
                    }
                    else
                    {
                        f.InnerJoin <ViewEntity>(join.Table, join.Where);
                    }
                }
            }

            QuerySection <ViewEntity> query = f.Select(creator.Fields).Where(creator.Where)
                                              .OrderBy(creator.OrderBy);

            return(new QuerySection(query));
        }
示例#2
0
 /// <summary>
 /// 进行查询操作
 /// </summary>
 /// <param name="fields"></param>
 /// <returns></returns>
 public TableRelation <T> Select(params Field[] fields)
 {
     section.Select(fields);
     return(this);
 }