Take the 2-minute tour ×  I got the error  cannot implicity
convert type
'System.Linq.IQueryable<EntityNetimoveis.San_Imovel>' to
'EntityNetimoveis.San_Imovel' An Explicit conversion exists (are
you missing a cast ?)  This occurs when I try the following code
EntityNetimoveis.San2011Entities db = new
EntityNetimoveis.San2011Entities(); EntityNetimoveis.San_Imovel
im = db.San_Imovel.Where(a => a.Credenciada_Id == 10);  What
type of conversion I have to do ?  share|improve this question
add comment  2 Answers  up vote 3 down vote accepted  The type
of im is an IQueryable<EntityNetimoveis.San_Imovel> because you
are running a where query and there might be more than one
result. If you want the first result matching your query you
should use .FirstOrDefault(). Try changing you code as:
EntityNetimoveis.San_Imovel im = db.San_Imovel.FirstOrDefault(a
=> a.Credenciada_Id == 10);  If you want to return more than one
entity and process them, lets say using a foreach loop, then you
need to change the type of the retu