Skip to content

a class by reflection to work with querystrings easily

Notifications You must be signed in to change notification settings

yeganehaym/EasyQueryString

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyQueryString

a class by reflection to work with querystrings easily

EasyQueryString

easyquerystring helps you establish a connection between your property names and query string names.you dont have to follow rule that query string field name must be same as class property name anymore

On Nuget: Install-Package EasyQueryString

look at below code:

this is querystring: current=1&rowCount=10&sort[sender]=asc&searchPhrase=keyword

public class EmployeesRequestBody
{
    [RequestBodyField("current")]
    public  int CurrentPage { get; set; }
 
    [RequestBodyField("rowcount")]
    public int RowCount { get; set; }
 
    [RequestBodyField("searchPhrase")]
    public string SearchPhrase { get; set; }
 
    [RequestBodyField("sort")]
    public NameValueCollection SortDictionary { get; set; }
}

now write this code

public ActionResult yourMethod()
{
  EmployeesRequestBody data = Requests.GetFromQueryString<EmployeesRequestBody>();
  // EmployeesRequestBody data = Requests.GetFromQueryString<EmployeesRequestBody>(RequestType.POST);
  return View(data);
}

About

a class by reflection to work with querystrings easily

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published