I currently am pulling a list of url's from a view using Entity Framework 5 and MVC 5. I need to populate a list of url's in the view from this database view. Currently I have:

Repository:

public class LinkRepository
{
    private readonly LinkLibrary _entities = new LinkLibrary ();


    public LinkRepository()
    {
        _entities = new LinkLibrary ();
    }


    public List<LinkModels> RetrieveStateLink(string year)
    {
        return
            _entities.vw_URLLibrary.Where(s => s.YEAR.Equals(year) && s.URL_TYPE.Equals("United States")).Select(m => new LinkModels()
            {
                UrlLink = m.LinkLocation
            }).ToList();
    }
}

Model

public class LinkModels
{
    public string LinkYear { get; set; }
    public string LinkState { get; set; }
    public string UrlLink { get; set; }
    public string LinkType { get; set; }
    public List<string> ListOfUrls{ get; set; }
}

Controller

public ActionResult GetStateLinks()
    {
        var stateLink = new List<string>();
        var model = rr.RetrieveStateLinks("2014").Select(m=> m.UrlLink).ToList();
        foreach (var s in model)
        {
            stateLink.Add(s);
        }

        var rm = new LinkModels();
        rm.ListOfUrls = stateLink;

        return View(rm.ListOfUrls);
    }

View

<ol>
    @foreach (var item in Model.ListOfUrls)
    {
        <li>
            @Html.ActionLink("state", "GetStateLinks", new { mystring = item })
        </li>
    }
</ol>

I am unsure how to pass this into the view to where it will display:

Alabama.aspx Georgia.aspx

Related posts

Recent Viewed