我在 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_id
和company
=name of compay
匹配cl.company_id