2012-06-18 4 views
0

ASP.NET C#에서 내 응용 프로그램, SQL에서 linq 데이터베이스에서 데이터를 전달하는 데 사용합니다. SQL에Linq C에서 # : ID를 통해 이름을 얻는 방법

Linq에 아래에 내 코드 :

Figure

내 코드 :

public class course_list 
     { 
      //Id of event    
      public int id { get; set; } 
      // Name of event 
      public string name { get; set; } 
      //type of event 
      public string e_type { get; set; } 
      //name of the compay 
      public string compay { get; set; } 
     } 
     // Get data 
     protected void show_event() 
     { 
      for_testDataContext db = new for_testDataContext(); 
      IQueryable<course_list> CourseList = from cl in db.events 
               select new course_list() 
               { 
                id = cl.id, 
                name = cl.name, 
                e_type = cl.e_type_id, // how to get name of e_type 
                compay = cl.company_id //How to get name of company 
               }; 

     } 
e_type = name of e_type 경기 cl.e_type_idcompany = name of compay 일치를 할당하는 방법

cl.company_id

답변

4
select new course_list 
{ 
    id = cl.id, 
    name = cl.name, 
    e_type = cl.e_type.name, 
    company = cl.company.name 
}; 
+0

정말 고마워. 아주 쉽게,하지만 나와 함께 매우 어려운 :) – Hainlp