Hello,
We are working on a custom module and we need to be able to get ParagraphPageIDs from the Paragraph table where ParagraphModuleSystemName matches a passed in value.
How would this be done?
Thank you
Hello,
We are working on a custom module and we need to be able to get ParagraphPageIDs from the Paragraph table where ParagraphModuleSystemName matches a passed in value.
How would this be done?
Thank you
Hi D W,
You can do that with this query
SELECT ParagraphPageID FROM Paragraph WHERE ParagraphModuleSystemName = '{Your_Value_Here}'
Best Regards,
Nuno Aguiar
We had the query figured out (that's how we knew the column names), but we were under the impression that the repo interface was the way to go.
How do you implement SQL queries like that in DW?
Hi D W,
Assuming you are using C# to build your custom module, you can do something like this:
var sqlCommandText = CommandBuilder.Create("YOUR QUERY HERE")
using (IDataReader dataReader = Dynamicweb.Data.Database.CreateDataReader(sqlCommandText)) { while (dataReader.Read()) { // Your code here } }
Best Regards,
Nuno Aguiar
Thank you. That worked for us (we had to play with it a little and for us it was Dynamicweb.Database, not Dynamicweb.Data.Database).
Great, sorry about that. I was copy-pasting and typing some from memory. Glad you got it working
Another option is to use the API to get a subset of the cached paragraphs and take the page ids from there:
var pageIds = Dynamicweb.Services.Paragraphs.GetParagraphsByModuleName("MyModuleName").Select(paragraph => paragraph.PageID);
OR
var pages = Dynamicweb.Services.Paragraphs.GetParagraphsByModuleName("MyModuleName").Select(paragraph => paragraph.Page);
You must be logged in to post in the forum