For example, the users of our app want to search products by entering a keyword of productName.
The Products table of the sql server database contains about 10 million records.
Are there any better and higher-performance search methods to implement instead of productName.Contains("keyword") using asp.net C# ?
I'm using stored procedures now, but linq to sql or entity framework are also a possibility.
Displaying Data from a Database. Once you've got a database with data in it, you can display the data in an ASP.NET web page. To select the table rows to display, you use a SQL statement, which is a command that you pass to the database.
The Visual Studio web project templates use SQL Server for the ASP.NET membership database by default. Nearly all ASP.NET documentation on the MSDN web site, ASP.NET web sites, and in blog posts uses SQL Server.
If you want better performance then you could look into a full text search. Note that this is currently not supported by LINQ to SQL but you can write the SQL in a stored procedure and call the stored procedure from your application. The accepted answer for this StackOverflow post recommends reading this article.
Well you could achieve this from the db side using a LIKE
LIKE (Transact-SQL)
Something like
DECLARE @Table TABLE(
Val VARCHAR(50)
)
INSERT INTO @Table SELECT 'asdf'
INSERT INTO @Table SELECT 'tada'
INSERT INTO @Table SELECT 'foo'
INSERT INTO @Table SELECT 'bar'
INSERT INTO @Table SELECT 'test'
INSERT INTO @Table SELECT 'test foo'
DECLARE @Lookup VARCHAR(50)
SELECT @Lookup = 'foo'
SELECT *
FROM @Table
WHERE Val LIKE '%' + @Lookup + '%'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With