Which do you prefer and why?
db.Query<Student>("Select * from Students").ToList();
or
db.Query<Student>("Select Id, FirstName, LastName, Address, Age, Etc From Students").ToList();
Which do you prefer and why?
db.Query<Student>("Select * from Students").ToList();
or
db.Query<Student>("Select Id, FirstName, LastName, Address, Age, Etc From Students").ToList();
In terms of RDBMS
More the descriptive, better for RDBMS. This is because, RDBMS do not need to resolve the symbols.
So, Select Id,.... From Students
is better. Because with this, RDBMS do not need to resolve the *
.
Also, with this you may easily limit the columns you want to select. This is not a good comparison though because *
vs selected columns
might be different topic.
Further, Select Id,.... From dbo.Students
is even better. This also tells RDBMS where does Students
table belong; so even less work for RDBMS.
Not sure though, but I think, such descriptive queries help generating and reusing query execution plan in efficient way.
As you have not covered WHERE
clause in your sample, I will not go into details there. Just to mention, parameterized queries are better choice.
In terms of Dapper
Dapper is O/R mapper. It sends the query you passed in to RDBMS without any change(really? anyway; different topic...). After receiving result from RDBMS, it simply maps the RDBMS specific data structure to your Entity.
There are many ways to make this mapping happen; please search Stack Overflow for more details. By default, it happens automatically if your column/property names and table/class names are same.
Hence, whether you do *
or selected columns
, does not matter to dapper.