vendredi 25 novembre 2016

what is name of the List

As we know that the List for C# is possible to put the function behind but do the function to filter the list.

For example, Assume that the many count inside the students List.

var students=new List<student>();

Then to get the list of student we can add some function behind like

students.find(id).sortbydesending(k=>k.x).skip(10).take(5).toList();

the sequence of putting the skip() and take() will effect the result.

I was doing the coding on an method to retrieve the list of student accordingly.

First, I want to do something similar with the list function. For example i need order the list Of Student According student name.

instead of doing

student.sortbydescending(k=>k.name).toList();

I want code is like

student.sortbyNamedesc().toList();

and it will return the same result as above.

Second is the design pattern name and (If possible) implementation guide

This is because I plan to do something like this.

getStudent().searchName(searchQuery).sortby(id);

Then i can get student name similar with search query and sort it by the student id instead of

getstudent(searchQuery,id,skip,take);

public IList<Student> getStudent(searchQuery,id,skip,take){
   var students=new List<student>();
   if(searchquery!="")
        student.where(x=>x.x==searchquery);

   if(skip!=null&&skip!=0)
        students.skip(skip);

   if(take!=null&&take!=0)
     students.take(take);

    return students;

  }

Aucun commentaire:

Enregistrer un commentaire