예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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}\")"));
        }
예제 #4
0
 public static SqlBuilder SelectCount(this SqlBuilder builder)
 {
     return(builder.Select("COUNT(*)"));
 }
예제 #5
0
 public static SqlBuilder SelectDistinct(this SqlBuilder builder, params Type[] types)
 {
     return(builder.Select("DISTINCT " + types.Select(x => TableMapping.Mapper.TableNameMapping(x) + ".*").Join(", ")));
 }
예제 #6
0
 public static SqlBuilder Select(this SqlBuilder builder, params Type[] types)
 {
     return(builder.Select(types.Select(x => $"\"{TableMapping.Mapper.TableNameMapping(x)}\".*").Join(", ")));
 }