/// <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)); }
/// <summary> /// 右关联 /// </summary> /// <param name="table"></param> /// <param name="onWhere"></param> /// <returns></returns> public TableRelation <T> RightJoin <TJoin>(Table table, WhereClip onWhere) where TJoin : Entity { section.RightJoin <TJoin>(table, onWhere); return(this); }