The best solution I found was to continue working on a table function in SQL that produces results like:
CREATE function [dbo].[getMatches](@textStr nvarchar(50)) returns @MatchTbl table( Fullname nvarchar(50) null, ID nvarchar(50) null ) as begin declare @SearchStr nvarchar(50); set @SearchStr = '%' + @textStr + '%'; insert into @MatchTbl select (LName + ', ' + FName + ' ' + MName) AS FullName, ID = ID from employees where LName like @SearchStr; return; end GO select * from dbo.getMatches('j')
Then you simply drag and drop the function into your LINQ.dbml designer and name it the same as other objects. LINQ even knows the columns of your stored function. I call it the following:
Dim db As New NobleLINQ Dim LNameSearch As String = txt_searchLName.Text Dim hlink As HyperLink For Each ee In db.getMatches(LNameSearch) hlink = New HyperLink With {.Text = ee.Fullname & "<br />", .NavigateUrl = "?ID=" & ee.ID} pnl_results.Controls.Add(hlink) Next
Incredibly simple and really applying the power of SQL and LINQ in the application ... and you, of course, can generate any function that you need for the same effects!
beauXjames Jun 18 2018-10-18 18:52
source share