I am trying to select a row
[and in a comment…]
I was trying to get the whole row which has several data types.
Then you don’t need to Cast()
or ToList()
. If you want a single record, just fetch that single matching record:
return database.Staff_Mod_TBLs
.Single(staff => staff.Staff_No == staffNo);
or, if you want to return null
instead of throwing an error when there’s no match:
return database.Staff_Mod_TBLs
.SingleOrDefault(staff => staff.Staff_No == staffNo)
Then of course you’d need to change the method’s return type:
public static Staff_Mod_TBL ModValues(...)
(Assuming the type name based on the table name. Substitute as needed if it’s different.)
Basically, what you are looking for is an instance of the object which represents a record in that table. Not a collection of column values.
4
solved Create a class that will hold a LINQ query?