How to use Contains function in Linq to Sql
By bryan tugade
We can also use the Contains function in searching a data in the database in Linq to Sql.
Partial Class _Default
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Dim pContext = New AWData()
Dim prod = (From p In pContext.Products Where p.Name.Contains("A") Select p)
For Each product In prod
Response.Write(product.Name & "<br/>")
The Like, StartsWith and Contains are can be used as alternative function in searching a specific records in a database in Linq to Sql.
This topic will show us on how to search a data in a database using SqlMethods.Like in Linq to Sql
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 Contains function in Linq to Sql (1196 Views)