views:

20

answers:

1

I have the following Iqueryable method to show details of a singl material,

public IQueryable<Materials> GetMaterial(int id)
{
    return from m in db.Materials
           join Mt in db.MeasurementTypes on m.MeasurementTypeId equals Mt.Id
           where m.Mat_id equals id
            select new Materials()
            {
              Id = Convert.ToInt64(m.Mat_id),
              Mat_Name = m.Mat_Name,
              Mes_Name = Mt.Name,
            };
}

Any suggestion....

A: 

Your where clause should be a boolean expression, like this:

where m.Mat_id == id

You use the keyword equals for joins, but a where clause should use a boolean expression, think of it this way: whatever is in where something it should work as if it were in a if(something).

Nick Craver