I selected 4 columns from my table by using select statement LINQ to SQL. Then I create a new List to store the query result. BUT, the code room.ToList(); is WRONG.
Why cannot we use "rooms_list = room.ToList()"?
How should we do to solve the problem???
Thanks for teaching me!
private void btnTest_Click(object sender, EventArgs e)
{
List<string> rooms_list = new List<string>();
using (LVDatabaseEntities database = new LVDatabaseEntities())
{
var room = from x in database.PHONGCHOIs
select new { x.TENPHONG, x.MATKHAUPHONG, x.CHUPHONG, x.SOLUONG };
rooms_list = room.ToList();
}
MessageBox.Show(rooms_list.Count.ToString());
}