Here is my function:
Public Function ListPublishedArticles(ByVal startingDate As DateTime) As List(Of Article)
Dim db As ArticleEntities = ArticleEntitiesFactory.Current()
Dim listArticles As List(Of Article) = Nothing
If startingDate <> Nothing Then
listArticles = db.Articles.Where(Function(x) x.Publish = True And x.startTime <= startingDate)
End If
Return listArticles
End Function
On the .Where() I get the following error:
No Accessible 'where' can be called without narrowing conversion. Candidates are
Public Function Where(Of Article)(IEnumerable(Of Article), Func(Of Article, Boolean)) As IEnumerable(Of Article) (In Class Enumerable)
Public Function Where(Of Article)(IQueryable(Of Article), Expression(Of Func(Article, Boolean))) As IQueryable(Of Article) (In Class Queryable)
I understand the error but am not sure how to fix it, how do I tell it which one I am using? On msdn it says to ignore this error turn Option Strict to Off, but it is already off. It’s not showing up as an error in the error list at the bottom, just a red underline, but it is preventing me from continuing with .OrderBy() and anymore functions.
Thanks.
Well it seems like the answer was obvious and I just wasn’t getting, all I needed to do was CType the Where expression to either one of the types of the parameters like so: