This question is a continuation of the this question, How to bind a variable with multiple types? LINQ
I am trying to select a row of data that has 30 columns in it, the criteria is a unique value from the column Staff_No
. The row has several data types.
I can't get the the syntax correct and this is the code.
internal class DatabaseQueries
{
public static IEnumerable<int> ModValues(DatabaseDataContext database, int staffNo)
{
return database.Staff_Mod_TBLs
.Where(staff => staff.Staff_No == staffNo).Cast<int>().ToList();
}
}
The error is InvalidOperationException Class.
And this code gives me this error,
public static IEnumerable<decimal> ModValues(DatabaseDataContext database, int staffNo)
{
return database.Staff_Mod_TBLs
.Where(staff => staff.Staff_No == staffNo).Select(staff => staff.Days_No_D).ToList();
}
The error, Severity Code Description Project File Line Suppression State Error CS0266 Cannot implicitly convert type 'System.Collections.Generic.List<decimal?>' to 'System.Collections.Generic.IEnumerable<decimal>'. An explicit conversion exists (are you missing a cast?)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…