Exemple #1
0
        public ProductWithRowNoItem[] GetProjectsWithRowNumber(ProductWithRowNoItemArgs args)
        {
            List <SqlParameter> ps = new List <SqlParameter>();
            StringBuilder       sb = new StringBuilder();

            sb.Append(@"SELECT * FROM(
SELECT [pid]
      ,[name]      
      ,[imagePath]
	  ,ROW_NUMBER() OVER(order by sortNo DESC,updated DESC) rno
  FROM [dbo].[Product] p where 1=1 and enabled=1");
            if (!String.IsNullOrWhiteSpace(args.ClassNo))
            {
                sb.Append(" and p.classNo like @classNo");
                ps.Add(new SqlParameter("classNo", args.ClassNo + "%"));
            }
            sb.Append(" ) AS tb where 1=1 ");
            if (args.MinRno.HasValue)
            {
                sb.Append(" and rno>=@MinRno");
                ps.Add(new SqlParameter("MinRno", args.MinRno.Value));
            }
            if (args.MaxRno.HasValue)
            {
                sb.Append(" and rno<=@MaxRno");
                ps.Add(new SqlParameter("MaxRno", args.MaxRno.Value));
            }
            if (args.Pid.HasValue)
            {
                sb.Append("  and pid=@pid");
                ps.Add(new SqlParameter("pid", args.Pid.Value));
            }
            return(Context.Database.SqlQuery <ProductWithRowNoItem>(sb.ToString(), ps.ToArray()).ToArray());
        }
Exemple #2
0
 public Data.ProductWithRowNoItem[] GetProjectsWithRowNumber(Data.ProductWithRowNoItemArgs args)
 {
     return(_Repository.GetProjectsWithRowNumber(args));
 }