2

I have got the code below to return data from a table in my database.

I have tried and not been successful using stored procedures so can anyone advice how I use between two dates to get the below code to work.

Thanks

Imports System.Data.Entity

    Public Class HomeController
        Inherits System.Web.Mvc.Controller

    Private db As New ArticlesDBContextNew
        Function Index() As ActionResult
        ViewData("Message") = "Modify this template to jump-start your ASP.NET MVC application."

        Dim Articles = From Title In db.ArticlesList Select Title
        Articles = Articles.Where(Function(s) s.PublishdateFrom > (Date.Now.Date) And s.PublishDateTo > (Date.Now.Date))
        Return View(db.ArticlesList.ToList())
        Return View(Articles)
            Return View()
        End Function

        Function About() As ActionResult
            ViewData("Message") = "Your app description page."

            Return View()
        End Function

        Function Contact() As ActionResult
            ViewData("Message") = "Your contact page."

            Return View()
        End Function
    End Class
user2029541
  • 666
  • 3
  • 12
  • 22
  • Unless your queries are extremely complicated, why not use the benefits of EF and LINQ? Why give yourself two sets of code to maintain? – Matt M Aug 15 '13 at 20:55

1 Answers1

3

You should be able to call it (via LINQ) like any other function. Here is a good SO question with example code. calling stored procedure with linq

Community
  • 1
  • 1
tgolisch
  • 6,549
  • 3
  • 24
  • 42