Query custom table in Umbraco DB

I was successful in creating the DB using NPoco but am having trouble getting the data from a function in my surface controller. I am trying to return a single email based on the query. I can’t find a decent example of how to do this. I am pretty new to Umbraco and primarily a front end developer so I am giving this my best shot.

Here is my query

    public string GetEmail(string Locations)       {

        using (var scope = _scopeProvider.CreateScope())
        {
            var db = scope.Database;
            var record = db.Query<ContactViewModel>("SELECT Location FROM EmailList WHERE [Location] = @Locations");

            return null;
        }
    }

I am not sure how to wrap the query in a function. No matter what I do it just seems to fail.


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/109621-query-custom-table-in-umbraco-db