0

我在 ASP.NET C# 中的应用程序,我使用 linq to sql 从数据库传递数据。我的代码如下

LINQ转SQL:

数字

我的代码:

    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

1 回答 1

4
select new course_list
{
  id = cl.id,
  name = cl.name,
  e_type = cl.e_type.name,
  company = cl.company.name
};
于 2012-06-18T07:36:34.313 回答