i have a t_my_class table structure like below (MySql table)
id class group age name surname
1 9 A 18 sarah brown
2 10 B 20 joe sanders
3 8 A 17 elisa connor
4 10 C 23 sandra brown
and i have a struct and a list of that struct
struct MyClass
{
int id;
string class;
string group;
int age;
string name;
string surname;
}
List<MyClass> Students = new List<MyClass>();
Now, can u tell me which LINQ query to use to select all data from t_my_class table to Students List.
Firstly, that should almost certainly not be a
struct– it should be aclass. Now, you have a couple of choices; if you do already have a LINQ-enabled ORM hooked up, then it should be simply:If you aren’t already using an ORM tool then a micro-ORM might help, for example dapper-dot-net works with MySql AFAIK, allowing:
With: