public static IEnumerable <T> QueryJoined <T, T2, T3, T4, T5>(this IDatabase db, SqlBuilder builder, Func <T, T2, T3, T4, T5, T> mapper) { var type = typeof(T); var sql = builder.Select(type, typeof(T2), typeof(T3), typeof(T4), typeof(T5)).AddSelectTemplate(type); return(db.Query(sql.RawSql, mapper, sql.Parameters)); }
public static IEnumerable <T> Query <T>(this IDatabase db, SqlBuilder builder) { var type = typeof(T); var sql = builder.Select(type).AddSelectTemplate(type); return(db.Query <T>(sql.RawSql, sql.Parameters)); }
public static SqlBuilder SelectCountDistinct <TModel>(this SqlBuilder builder, Expression <Func <TModel, object> > property) { var table = TableMapping.Mapper.TableNameMapping(typeof(TModel)); var propName = property.GetMemberName().Name; return(builder.Select($"COUNT(DISTINCT \"{table}\".\"{propName}\")")); }
public static SqlBuilder SelectCount(this SqlBuilder builder) { return(builder.Select("COUNT(*)")); }
public static SqlBuilder SelectDistinct(this SqlBuilder builder, params Type[] types) { return(builder.Select("DISTINCT " + types.Select(x => TableMapping.Mapper.TableNameMapping(x) + ".*").Join(", "))); }
public static SqlBuilder Select(this SqlBuilder builder, params Type[] types) { return(builder.Select(types.Select(x => $"\"{TableMapping.Mapper.TableNameMapping(x)}\".*").Join(", "))); }