Some time ago, because the basic idea of Data Center reconstruction was not clearly understood, and there were too many concepts around it, I wanted to add everything at the beginning, so it was overwhelmed and started slowly. Later, lianggetiao added things at, which is much better.
For generic collections, there are a lot of details that have been written by the goddess of male. However, only the knowledge I have summarized can be printed in my mind. Let me write my own understanding.
After reading the relevant information about generic collections (blog, design patterns, and other online introductions ...), Logic:
What is it?
[Generics are classes, structures, interfaces, and methods with placeholders (type parameters. These Placeholders are one or more types of placeholders stored or used by classes, structures, interfaces, and methods.
A generic collection class can use a type parameter as a placeholder for the type of the object it stores. A type parameter is used as the type of its field and the parameter type of its method.] -- Msdn
A generic set is actually a collection of entity classes. Before we get started with this concept, the types returned by database access include entities, datatable, and Boolean. Below are several images:
What are the benefits?
If you do not need a generic set, If you query the number of users (add and delete users), a single entity and Boolean will certainly not work, but datatable will do, you can modify the datatable because of its high coupling (a user information changes, so that the system performance will be poor.
How to use it?
First, we understand that datatable is converted to a generic set by writing a conversion method in the conversion class, and then instantiates the return type of the class at Layer D.
Dim mylist as new list (of object class) mylist = getgenerics. converttolist (of object class) (object returned by datatable)
For example:
<span style="font-size:18px;">Dim mylist As New List(Of Entity.Users)mylist = GetGenerics.ConvertToList(Of Entity.Users)(dt)</span>
<span style="font-size:18px;">Return mylist</span>
Then the returned value is a generic set.
In this learning process, I feel a lot of experience, from simple to deep, 1.1 drops of accumulation, thick accumulation.
I hope you guys can give us some advice if you have any mistakes.
Datatable into a generic set