public SqlProvider <T> FormatExists() { var selectSql = "SELECT TOP 1 1"; var fromTableSql = FormatTableName(); var whereParams = ResolveExpression.ResolveWhere(Context.QuerySet.WhereExpression); var whereSql = whereParams.SqlCmd; Params = whereParams.Param; SqlString = $"{selectSql} {fromTableSql} {whereSql}"; return(this); }
public SqlProvider <T> FormatSum(LambdaExpression lambdaExpression) { var selectSql = ResolveExpression.ResolveSum(typeof(T).GetProperties(), lambdaExpression); var fromTableSql = FormatTableName(); var whereParams = ResolveExpression.ResolveWhere(Context.QuerySet.WhereExpression); var whereSql = whereParams.SqlCmd; Params = whereParams.Param; SqlString = $"{selectSql} {fromTableSql} {whereSql} "; return(this); }
public SqlProvider <T> FormatToList() { var selectSql = ResolveExpression.ResolveSelect(typeof(T).GetProperties(), Context.QuerySet.SelectExpression, Context.QuerySet.TopNum); var fromTableSql = FormatTableName(); var whereParams = ResolveExpression.ResolveWhere(Context.QuerySet.WhereExpression); var whereSql = whereParams.SqlCmd; Params = whereParams.Param; var orderbySql = ResolveExpression.ResolveOrderBy(Context.QuerySet.OrderbyExpressionList); SqlString = $"{selectSql} {fromTableSql} {whereSql} {orderbySql}"; return(this); }
public SqlProvider <T> FormatUpdateSelect(Expression <Func <T, T> > updator) { var update = ResolveExpression.ResolveUpdate(updator); var selectSql = ResolveExpression.ResolveSelectOfUpdate(typeof(T).GetProperties(), Context.QuerySet.SelectExpression); var where = ResolveExpression.ResolveWhere(Context.QuerySet.WhereExpression); var whereSql = where.SqlCmd; Params = where.Param; Params.AddDynamicParams(update.Param); var topSql = Context.QuerySet.TopNum.HasValue ? " TOP " + Context.QuerySet.TopNum.Value : ""; SqlString = $"UPDATE {topSql} {FormatTableName(false)} WITH ( UPDLOCK, READPAST ) {update.SqlCmd} {selectSql} {whereSql}"; return(this); }