Working with database from inside an module

Topics: Writing modules
Feb 6, 2014 at 11:53 AM
I'm new to Orchard, my goal is to develop a new module, that will attach a profile to the current existing users, I have developed already a content part that will handle the edit/display of the profile data, what I don't understand is how I can query directly the database to get for example all users from a specific role? (I don't want to get all UserRolesPartRecords but instead I want to get only those that contain a specific role), in order to populate a dropdownlist on the edit view to be able to associate the profile with an existing user.
The above is just an example, what if I would like to define a contentpart that will incorporate for example a grid or complex forms like cascading dropdownlists, how do I use the database? (in entity framework I would just write a linq to entity and that's it, but in here the level of abstraction and lack of proper documentation makes me wonder even if such thing is possible).
I'm interested in in deep customization not simple create, update, delete functions.......

There is no tutorial, neither any good documentation of how to handle such cases.