Type or namespace name could not be found
- by Pandiya Chendur
I use this:
public IQueryable<MaterialsView> FindAllMaterials()
{
var materials = from m in db.Materials
join Mt in db.MeasurementTypes on m.MeasurementTypeId
equals Mt.Id
select new MaterialsView {
MatId = m.Mat_Name,
MesName = Mt.Name,
MesType = m.Mat_Type };
return materials;
}
It gives me the following errors:
The type or namespace name MaterialsView could not be found (are you missing a using directive or an assembly reference?)
Cannot implicitly convert type System.Collections.Generic.IEnumerable<MaterialsView> to System.Linq.IQueryable<MaterialsView>. An explicit conversion exists (are you missing a cast?)
The type arguments for method System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>) cannot be inferred from the usage. Try specifying the type arguments explicitly.
I have googled it and found this SO question but it doesn't help.
What's wrong?