-4

所以据我所知,我需要能够从我的数据库模型中返回所有记录:

    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; }
}

我正在使用实体框架、C# 和 Asp.Net。我需要能够将所有这些记录返回到List<>

4

1 回答 1

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
            }
        }
于 2013-01-18T18:36:11.540 回答