Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...IHydratable and ArraysIHydratable and Arrays
Previous
 
Next
New Post
9/9/2009 6:12 AM
 

(Simplifying:) I am creating a module that is a book catalog.

In SQL Server I have 3 tables to store this book catalog.
If every book has just 1 author I could suffice with just 1 table. But there are books that have multiple authors.
The 3 tables in SQL Server look like this.

The first table (BookDetails) has the following fields:
BookID                    (int)
YearOfPublishing (int)
Title                          (nvarchar)

The second table (Authors) has the following fields:
AuthorID      (int)
FirstName  (nvarchar)
LastName  (nvarchar)

The third table links the first 2 tables and has the fields:
ID             (int)
ArticleID  (int)
AuthorID  (int)


In DotNetNuke I created a BookInfo class with arrays of string as data types for the FirstName and LastName properties.
This to be able to store multiple authors for 1 book.
So the BookInfo class has the following properties:
YearOfPublishing as Integer
Title                   as String
FirstName()     as String
LastName()     as String

How do I tie this all up within the IHydratable Fill method?
Can it be done or should I use another approach?

Help is much appreciated.

 
New Post
9/9/2009 10:09 AM
 

Hi

I would suggest creating an AuthorInfo class.  Then altering your BookInfo class to have a collection of AuthorInfo objects.  then after you have populated the basic BookInfo using the ihydrateable fill,  use a AuthorsController to get the collection of Authors related to that Book.   You could even leave the AUthorInfo collection out of the BookInfo object and just grab the related books when needed.

 

 

 
New Post
9/10/2009 5:23 AM
 

Thank you Robert.

(Given your first solution:)

At what point in time would I fill the collection of Authors? I guess the (implementation of the) Fill method of the IHydratable interface doesn't lend itself for it, or does it?

Would not using the IHydratable interface slow things down or doesn't that apply to the solution you suggest?

 

 
New Post
9/10/2009 9:50 AM
 

You would still use the ihydratablen interface for the BookInfo class and the AuthorInfo class.  In your Bookinfo fill method you would only be mapping the basic bookinfo.  

Your code for populating a single bookinfo object might look like this:

 

Dim objBooks As New BooksController
Dim objBook As BookInfo

Dim objAuthors As New AuthorsController

objBook = objBooks.GetBook(BookID, PortalId)

objBook.Authors = objAuthors.getAuthorsByBookID(BookID, PortalID)

 

that should do it.

 

 

 

 
New Post
9/10/2009 11:06 AM
 

Thanks again Robert.

Robert wrote
You would still use the ihydratablen interface for the BookInfo class and the AuthorInfo class.  In your Bookinfo fill method you would only be mapping the basic bookinfo.

Ok, that's clear.

Robert wrote

Your code for populating a single bookinfo object might look like this:

Dim objBooks As New BooksController
Dim objBook As BookInfo

Dim objAuthors As New AuthorsController

objBook = objBooks.GetBook(BookID, PortalId)

objBook.Authors = objAuthors.getAuthorsByBookID(BookID, PortalID)

that should do it. 

Don't I introduce the same problem at the objAuthors / AuthorsController side? This because an author can write multiple books, just like a book can be written by multiple authors. Within "objAuthors.getAuthorsByBookID" I would have to call "CBO.FillCollection" that uses (if I'm not mistaken) the IHydratable.Fill method.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...IHydratable and ArraysIHydratable and Arrays


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out