Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have been looking into linq for quite sometime now. I noticed that most examples do not include a straight link to a database.

here is what I have

Dim sqlconn1 As New SqlConnection("my database connection")
        Dim sqladaptor = New SqlDataAdapterDim db As DataContext = New DataContext(sqlconn1)
        db.Connection.Open()


however, I can not seem to use it this way and I noticed there was a mapping section.

db.mapping

how can I connect to my database using linq?

What I have tried:

read multiple articles including: How to: Connect to a Database - ADO.NET | Microsoft Docs[^] However, I just can not seem to populate the linq query appropriately to manifest the results I need.
Posted
Updated 17-Oct-20 22:33pm

1 solution

Maybe this will be helpful, but it involves using the Database Explorer:
How to: Query a Database by Using LINQ - Visual Basic | Microsoft Docs[^]

And also: Using LINQ to SQL in Visual Basic[^]

Another option would be to load the data in a DataSet and query that with LINQ:
Loading Data Into a DataSet - ADO.NET | Microsoft Docs[^]
And: Query Expression Syntax Examples: Projection (LINQ to DataSet) - ADO.NET | Microsoft Docs[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900