How to use SqlMethods.Like in Linq to Sql
By bryan tugade
This topic will show us on how to search a data in a database using SqlMethods.Like in Linq to Sql
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Dim pContext = New AWData()
Dim strLike As String = "%" & "ad" & "%"
Dim prod = (From p In pContext.Products Where SqlMethods.Like(p.Name, strLike) Select p Take 10)
For Each product In prod
Response.Write(product.Name & "<br/>")
Again i'm using AdventureWorks as my database.
That's it! Happy Coding.
We can select multiple fields in a given database tables using Linq to sql. I use AdventureWorks as my database in this sample app and to show you how it works i bind the results in gridview control.
This topic will show us on how to find data that starts with a given character using StartsWith function in Linq to Sql.
We can easily bind gridview using linq to sql. Assuming that your using AdventureWorks as your database.
We could get specific rows in the database table by skip and take using Linq to Sql. Here is the sample code.
We can show Distinct data in gridview using Linq to SQL. We can compare in the result how the distinct function works in Linq to sql. Here's how.
How to use SqlMethods.Like in Linq to Sql (1089 Views)