如何在我的特定情况下实现IEnumerable?

时间:2016-07-20 07:31:37

标签: c# entity-framework ienumerable

我之前已经问过我的问题,但即使以前所有的帖子都无法解决。很明显,我没有理解它。

我让Visual Studio生成了一个ADO NET Entity Framework Model,Code首先来自数据库。在数据库中,我有一个名为Finishes的表(用于保存游戏的每个可能的结尾,只是为了澄清)。一切正常。现在我需要实现IEnumerable以便能够遍历它。到目前为止,我了解一切。我似乎无法以某种方式做到这一点。也许有人可以照亮它,所以我会一劳永逸地理解。

Visual Studio已生成两个类;

Checkoutlist.cs:

namespace Bull.Models
{
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Collections;

public partial class CheckoutList : DbContext, IEnumerable
{
    public CheckoutList()
        : base("name=DatastoreConnection")
    {
    }

    public virtual DbSet<Finish> Finishes { get; set; }


    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Finish>()
            .Property(e => e.First)
            .IsFixedLength();

        modelBuilder.Entity<Finish>()
            .Property(e => e.Second)
            .IsFixedLength();

        modelBuilder.Entity<Finish>()
            .Property(e => e.Third)
            .IsFixedLength();
    }
}
}

和Finish.cs:

namespace Bull.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;

public partial class Finish
{
    public int Id { get; set; }

    public int Total { get; set; }

    [Required]
    [StringLength(10)]
    public string First { get; set; }

    [Required]
    [StringLength(10)]
    public string Second { get; set; }

    [Required]
    [StringLength(10)]
    public string Third { get; set; }
}
}

所以问题是;在我的情况下如何实现IEnumerable?非常感谢您的帮助(以及可能的解释)。

1 个答案:

答案 0 :(得分:2)

尝试使用此方法:

<div class="shape">
  <div class="shape__inner">
    <span style="font-size:72px;">7</span>
    <span style="font-size:18px;">minutes to Applecross High School</span>
  </div>
</div>