Mark Tabor

Mark Tabor

  • 548
  • 2k
  • 460.4k

Invalid column name ‘Course_Tags’. in razor View

Jan 17 2020 10:47 AM
Hi I am having a mvc web application in which I have four tables and i am using below linq query to get all columns from all tables and i inspect it using debugging it is getting all data from all four tables ,
  1. var dept = from s in db.Teacher_courses  
  2. join ce in db.Courses on s.CourseId equals ce.Course_Id  
  3. join se in db.Semesters on s.Semester_Id equals se.Semester_Id  
  4. join re in db.Registration on s.Teacher_Id equals re.User_Id  
  5. where ce.Course_Id == s.CourseId  
  6. select s;  
I have below Model class previously i was only getting data from Teacher_Courses Table but now I need to add more columns like semester,Registration and Courses table , so for experiment I just wrote the above query and inpect it using debugging it is getting all fields values from all tables , so I add one more property to my model class for Courses_TAGS as shown below
 
 
 
and i am using it in my view as shown below
  1. <td>  
  2. @Html.DisplayFor(modelItem => item.regs.FullName)  
  3. </td>  
  4. <td>@Html.DisplayFor(modelItem => item.Course_Tags)</td>  
but i am getting this below error message
 
 

Answers (5)