Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function GetDocuments(criteria as String)
- Dim splitCriteria = SplitTheCriteria(criteria)
- dim query = from document in _context.Documents
- For Each item in splitCriteria
- Dim localItem = item
- query = AddCriteriaToQuery(query, localItem)
- Next
- dim matchingDocuments = query.ToList()
- End Function
- Private Function AddCriteriaToQuery(query as IQueryable(Of Document), criteria as string) as IQueryable(Of Document)
- return query.Where(Function(doc) doc.Name = criteria)
- End Function
- Public Class Doc
- Private _docName As String
- Public Property DocName() As String
- Get
- Return _docName
- End Get
- Set(ByVal value As String)
- _docName = value
- End Set
- End Property
- Public Sub New(ByVal newDocName As String)
- _docName = newDocName
- End Sub
- End Class
- Sub Main()
- Dim Documents As New List(Of Doc)
- Documents.Add(New Doc("ABC"))
- Documents.Add(New Doc("DEF"))
- Documents.Add(New Doc("GHI"))
- Documents.Add(New Doc("ABC DEF"))
- Documents.Add(New Doc("DEF GHI"))
- Documents.Add(New Doc("GHI LMN"))
- Dim qry = From docs In Documents
- qry = qry.Where(Function(d) d.DocName.Contains("GHI"))
- Dim qryResults As List(Of Doc) = qry.ToList()
- For Each d As Doc In qryResults
- Console.WriteLine(d.DocName)
- Next
- End Sub
- query = query.where(Function(s) s = "ABC")
Add Comment
Please, Sign In to add comment