I have the following query:
tblVAL tblval = db.tblVALs.Where(p => p.PID == pid);
Note that I expect to get a list of items that should be returned.
tblVAL is a table in Entity Framework. NOTE THAT I NEED A LIST OF ITEMS TO BE RETURNED AS THERE CAN BE MORE THAN 1 ITEMS THAT IS RETURNS. AS SUCH, I DO NOT WANT TO USE First(), etc.
I get the following message
Cannot implicitly convert type ‘System.Linq.IQuerable to wa.Models.tblVAL’. An implicit converion exist (are you missing a cast? )
Your query is returning a collection. You need to call
SingleOrDefault,Single,First, orFirstOrDefaultto get a single record.If you want a collection, change your variable type to a collection:
You can also call
ToListto force query execution: