public override SqlProvider FormatToPageList <T>(int pageIndex, int pageSize) { var orderbySql = ResolveExpression.ResolveOrderBy(); var selectSql = ResolveExpression.ResolveSelect(null); var fromTableSql = FormatTableName(); var whereSql = ResolveExpression.ResolveWhereList(); var joinSql = ResolveExpression.ResolveJoinSql(JoinList, ref selectSql); var groupSql = ResolveExpression.ResolveGroupBy(); var havingSql = ResolveExpression.ResolveHaving(); SqlString = $@" SELECT T2.* FROM( SELECT T.*,ROWNUM ROWNUMS FROM ( {selectSql} {fromTableSql} {joinSql} {whereSql} {groupSql} {havingSql} {orderbySql} ) T )T2 WHERE ROWNUMS BETWEEN {((pageIndex - 1) * pageSize) + 1} and {pageIndex * pageSize}"; return(this); }
public override SqlProvider FormatToList <T>() { var topNum = DataBaseContext <T>().QuerySet.TopNum; if (topNum.HasValue) { return(FormatToPageList <T>(1, topNum.Value)); } var selectSql = ResolveExpression.ResolveSelect(null); var fromTableSql = FormatTableName(); var whereSql = ResolveExpression.ResolveWhereList(); var joinSql = ResolveExpression.ResolveJoinSql(JoinList, ref selectSql); var groupSql = ResolveExpression.ResolveGroupBy(); var havingSql = ResolveExpression.ResolveHaving(); var orderbySql = ResolveExpression.ResolveOrderBy(); SqlString = $"{selectSql} {fromTableSql} {joinSql} {whereSql} {groupSql} {havingSql} {orderbySql}"; return(this); }
public override SqlProvider FormatGet <T>() { var selectSql = ResolveExpression.ResolveSelect(null); var fromTableSql = FormatTableName(); var whereSql = ResolveExpression.ResolveWhereList(); var joinSql = ResolveExpression.ResolveJoinSql(JoinList, ref selectSql); var groupSql = ResolveExpression.ResolveGroupBy(); var havingSql = ResolveExpression.ResolveHaving(); var orderbySql = ResolveExpression.ResolveOrderBy(); SqlString = $@"SELECT T.* FROM( {selectSql} {fromTableSql} {joinSql} {whereSql} {groupSql} {havingSql} {orderbySql} ) T WHERE ROWNUM<=1"; return(this); }
public override SqlProvider FormatCount() { var selectSql = "SELECT COUNT(1)"; var fromTableSql = FormatTableName(); var whereSql = ResolveExpression.ResolveWhereList(); string noneSql = string.Empty; //连表字符 var joinSql = ResolveExpression.ResolveJoinSql(JoinList, ref noneSql); if (!Context.Set.IsDistinct) { SqlString = $"{selectSql} {fromTableSql} {joinSql} {whereSql} "; } else { //字段解析字符 string countBySql = ResolveExpression.ResolveSelect(null); SqlString = $@"SELECT COUNT(*) FROM( {countBySql} {fromTableSql} {joinSql} {whereSql} )T"; } return(this); }
public override SqlProvider FormatUpdateSelect <T>(Expression <Func <T, T> > updator) { throw new DapperExtensionException("Oracle不支持修改并查询"); var update = ResolveExpression.ResolveUpdate(updator); var selectSql = ResolveExpression.ResolveSelect(null); var fromTableSql = FormatTableName(); var whereSql = ResolveExpression.ResolveWhereList(); SqlString = $"UPDATE {FormatTableName(false, false)} {update.SqlCmd} {whereSql}; {selectSql} {fromTableSql} {whereSql};"; return(this); }