Exemplo n.º 1
0
        private int queryPaginationCountRowYourWere(Parame input)
        {
            int count = db.Database.SqlQuery <int>("EXEC [dbo].[pagination_row_count] @table_name,@search_text,@yourwhere,@key_where",
                                                   new SqlParameter("@table_name", input.table_name),
                                                   new SqlParameter("@search_text", input.search_text),
                                                   new SqlParameter("@yourwhere", input.yourwhere),
                                                   new SqlParameter("@key_where", input.key_where)
                                                   ).FirstOrDefault();

            return(count);
        }
Exemplo n.º 2
0
 private object queryPaginationAndFilterYourWhereJSONnonPagination(Parame input)
 {
     try
     {
         return(queryPaginationYourWereJSON(input));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemplo n.º 3
0
        private IEnumerable <T> queryPaginationYourWere <T>(Parame input)
        {
            IEnumerable <T> items = db.Database.SqlQuery <T>("EXEC [dbo].[pagination] @table_name,@search_text,@yourwhere,@key_where,@page,@limit_page,@sortby,@sort_type",
                                                             new SqlParameter("@table_name", input.table_name),
                                                             new SqlParameter("@search_text", input.search_text),
                                                             new SqlParameter("@yourwhere", input.yourwhere),
                                                             new SqlParameter("@key_where", input.key_where),
                                                             new SqlParameter("@page", input.page),
                                                             new SqlParameter("@limit_page", input.limit_page),
                                                             new SqlParameter("@sortby", input.sortby),
                                                             new SqlParameter("@sort_type", input.sort_type)
                                                             ).ToList();

            return(items);
        }
Exemplo n.º 4
0
 //json
 private PaginationJSON queryPaginationAndFilterYourWhereJSON(Parame input)
 {
     try
     {
         PaginationJSON pagination = new PaginationJSON();
         pagination.items       = queryPaginationYourWereJSON(input);
         pagination.currentPage = input.page;
         pagination.limitRow    = input.limit_page;
         int count = queryPaginationCountRowYourWere(input);
         pagination.resultRow = count;
         return(pagination);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemplo n.º 5
0
        private object queryPaginationYourWereJSON(Parame input)
        {
            string items = db.Database.SqlQuery <string>("EXEC [dbo].[pagination_json] @table_name,@search_text,@yourwhere,@key_where,@page,@limit_page,@sortby,@sort_type",
                                                         new SqlParameter("@table_name", input.table_name),
                                                         new SqlParameter("@search_text", input.search_text),
                                                         new SqlParameter("@yourwhere", input.yourwhere),
                                                         new SqlParameter("@key_where", input.key_where),
                                                         new SqlParameter("@page", input.page),
                                                         new SqlParameter("@limit_page", input.limit_page),
                                                         new SqlParameter("@sortby", input.sortby),
                                                         new SqlParameter("@sort_type", input.sort_type)
                                                         ).FirstOrDefault();

            if (items != null)
            {
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                var result = json_serializer.DeserializeObject(items);
                return(result);
            }
            return(new object[] { });
        }