Welcome to the Milos Blog!

Thursday, January 17, 2008
Generic Sub Item Collections in Business Entities

The latest Milos version has a pretty neat enhancement in the business entity model: Sub item collections are now available as generics. Here's why that's cool:

So far, in order to create collections of sub items in business entities ("1-to-many relationships"), one had to create the individual item objects, as well as a collection class that could hold those items. The trouble with that is that it is a lot of work to create the collection class, and the only benefit of this class is a strongly typed interface. (The strongly typed interface is needed so one can access parent.Children[x] and then get all the properties on that object).

Using the new generic version of the sub item collection, one usually does not have to create a subclass. Instead, one just creates the class for the individual items, and then instantiates the generic version of the collection, with the generic being the item type.

Example: An invoice entity with a line item collection could simply instantiate an appropriate collection like so:

protected override void  LoadSubItemCollections()
{
   this.colLineItems =
       new GenericEntitySubItemCollection<LineItem>(
         this,
         "PK_LineItem",
         "FK_Invoice",
         "Invoices",
         "PK_Invoice",
         this.GetInternalData().Tables["LineItems"] );
}

For more details and a detailed explanation, consult the "How-To: Creating a Collection of Child Items" topic in the Milos documentation.

Of course, the old way is still supported as well. The main benefit of using the generic version is in creating collections by hand. When using any of the code generator tools, one isn't exposed to the collection anyway (in most cases), so the benefit is minimal. So far, the code generator tools do not use the generic collection yet. There are considerations around backward compatibility. However, we are considering to change the tools in the future...



Posted @ 4:05 PM by Egger, Markus (markus@code-magazine.com)


Post a Comment:

Comment Title (required):

Your Name (optional):

Your Email (optional):

Your Web Site (optional):

Your Comment (required):


Archive:
November, 2010 (1)
July, 2009 (2)
February, 2009 (2)
January, 2009 (1)
December, 2008 (1)
October, 2008 (3)
June, 2008 (1)
April, 2008 (3)
February, 2008 (1)
January, 2008 (1)
December, 2007 (1)
October, 2007 (2)
September, 2007 (2)
July, 2007 (1)
June, 2007 (2)
May, 2007 (4)
April, 2007 (6)
March, 2007 (8)
February, 2007 (3)
January, 2007 (2)
December, 2006 (2)
November, 2006 (2)


Blog Stats:
Posts: 51
RSS Syndication

Contact:

EPS Software Corp.
6605 Cypresswood Dr., Suite 300
Spring, TX 77379
United States

Phone: 832-717-4445
Email: info@MilosSolutionPlatform.com

Other EPS Properties

EPS Software Homepage
EPS Custom Software
CoDe Magazine
CoDe Focus Magazine
VFPConversion.com
WPFExperts.com
MarkusEgger.com

(c) by EPS Software Corp. 2001 - 2013