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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0IDID's always 0
Previous
 
Next
New Post
2/6/2007 7:01 PM
 
CBO.FillObject and CBO.FillCollection always invoke the default (parameterless) constructor then use reflection to access the info class's public properties. Thus, you must provide Public properties (both set and get) for each field that will be filled from the datareader.  For performance reasons and because I like to implement readonly properties for combining fields and sometimes lazy hydration of collections of other class objects, I find I'm using CBO.FillObject and CBO.FillCollection less and less now - takes more time and code to write custom fill methods, of course.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
2/7/2007 11:24 AM
 
Thanks for the update imagemaker. I did code the public properties in my info class using the get and set methods, but some of the data simply did not get populated. If I understand what you are saying, and correct me if I am wrong here; but you are saying that I need to have my properties match the field names that the stored procedure returns and that they are case sensitive. Is that right?

I haven't gone back and made my properties the same case as my field names - I like capitolized properties without underscores (Ex: NewsId, ModuleId). My company has a database design procedure that requires underscores in field names (Ex: news_ID, module_ID).

If this is the case; I wrongfully assumed that CBO.FillCollection would use the initializer constructor where the compiler would choose the best constructor using polymorphism and reflection (take a look at my second constructor). It would also explain how some of my data got populated and some data didn't. The single name fields (Content, Title, and Heading) were all populated, while my ID, DateTime, and the other multinamed fields were not.

Anyhoo, assuming all this is correct, the property names are my problem and knowing is half the battle. I think I understand the issue well enough to make ends meet now. I can either alias the field names in my stored procedures, or go and change all my code.

Thanks!

Cheers!
John Valentine
http://www.webinnovationsystems.com
 
New Post
2/7/2007 11:31 AM
 

The CBO methods are a convenience, and rely on some assumptions that are mentioned in this thread.

However, as I blogged here a few months ago, they should be used with caution as they have a significant performance impact.  In 4.4 we added custom hydrators (fill methods) for most of the common core objects that did not already have their own, as one of the changes made for performance.

I have also provided more detail on my own site about developing your own hydrators.


Charles Nurse
Chief Architect
Evoq Content Team Lead,
DNN Corp.

Want to contribute to the Platform project? - See here
MVP (ASP.NET) and
ASPInsiders Member
View my profile on LinkedIn
 
New Post
2/7/2007 12:27 PM
 
Thanks for the info cnurse. This is inline with what I was saying before. You are really only creating another constructor that takes an IDataReader as an argument... .NET can use polymorphism to determine which constructor to run, and you can throw the overhead associated with reflection out the window while still using the common business objects. Most people tend to generate their modules with CodeSmith or with the new DNN templates anyway. It would be simple to have this model implemented in a template update after changing the common business objects to support this method as well as reflection.

My own Info class has this exact same code (only in C# syntax):

public WyleNewsInfo(IDataReader dr) {
this.NewsId = Convert.ToInt32(dr["news_Id"]);
this.StatusId = Convert.ToInt32(dr["status_Id"]);
this.ModuleId = Convert.ToInt32(dr["module_Id"]);
this.Title = dr["title"].ToString();
this.DateEntered = Convert.ToDateTime(dr["date_Entered"]);
this.CreatedBy = dr["created_By"].ToString();
this.ExpirationDate = Convert.ToDateTime(dr["expiration_Date"]);
this.Content = dr["content"].ToString();
this.EditedDate = Convert.ToDateTime(dr["edited_Date"]);
this.EditedBy = dr["edited_By"].ToString();
this.Attachment = dr["attachment"].ToString();
this.Url = dr["url"].ToString();
this.Heading = dr["heading"].ToString();
this.TimesAccessed = dr["times_Accessed"].ToString();
this.LocationId = Convert.ToInt32(dr["location_Id"]);
this.GroupId = Convert.ToInt32(dr["group_Id"]);
}

It is exactly how I had my code working before. I see in your code you are looking for dr.Read() however if you were to put it in a while loop you can merge your two functions. Assuming you have your dr instanced:

List articles = new List();
while(dr.Read()) {
articles.Add(new WyleNewsInfo(dr));
}

return articles; // who cares if it returns an empty List. A datasource can handle the nill and display nothing without my having to write code to handle error trapping.


The basic thing that I see in your hydration code is that you are breaking away from the basic data encapsulation rules by moving your hydration code (which is really a constructor) out of your class an putting it into the business layer. Classes should always be self instantiating (hydrating).

Beyond that, I am happy to know that I was beating down the right path as most everyone else. Thanks for your contributions to DNN. I really do appreciate all the work you folks do!

Cheers!

Cheers!
John Valentine
http://www.webinnovationsystems.com
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0IDID's always 0


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