You can not directly talk to the database in your code without writing a selection of code to do so. Remebering that it is just .net code you will have to ..
1. Create the connection string
2. create the conection to the database
3. define the query object
4. pass this to an execution method
5. proces the results.
But if you are going to be reading the data from tables already defined as entities you can always just reference the collections and then use a linq query against them. This was Lightswitch will handle the relationships, connections and security for you.