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.
Huw, I do have another Question. I tried adding an attachment to the contact form using "public IFormFile Attachment { get; set; }" in my model. When it gets to the DB Query above it throws the error below. I am pretty sure it blows up on " db.Single".
InvalidProgramException: Common Language Runtime detected an invalid program.
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
I am not sure how to wrap the query in a function. No matter what I do it just seems to fail.
What errors are you getting?
Try changing your query to
I will try that Huw, thank you!
Worked like a charm Huw, thank you again!
Huw, I do have another Question. I tried adding an attachment to the contact form using "public IFormFile Attachment { get; set; }" in my model. When it gets to the DB Query above it throws the error below. I am pretty sure it blows up on " db.Single".
InvalidProgramException: Common Language Runtime detected an invalid program.
Would you know any resolution to this?
is working on a reply...