从我所知,我需要能够从我的数据库模型中返回所有记录:
public class Resort
{
public int ID { get; set; }
public String Name { get; set; }
public int BlackDiamond { get; set; }
public int BlueSquare { get; set; }
public int GreenCircle { get; set; }
public int TerrainPark { get; set; }
}
public class ResortDBContext : DbContext
{
public DbSet<Resort> Resorts { get; set; }
}
我正在使用Entity Framework,C#和Asp.Net。我需要能够将所有这些记录返回到List<>
答案 0 :(得分:1)
这样的事情怎么样:
using (var YourContext = new YourEntities())
{
List<Resort> resorts = (from resorts in YourContext.Resort
select resorts).ToList();
foreach (Resort resort in resorts)
{
//Do something here
}
}