Overridable GetFieldsInfo in TypedView

Posts   
 
    
everettm
User
Posts: 39
Joined: 17-Apr-2006
# Posted on: 13-Jun-2007 18:16:08   

I've used the following technique several times now with typed lists mapped to transactional data that our application accesses in both itemized and summary forms.

I use the designer to create the typed list such that it's tailored for itemized access to the data. Then, I'll inherit the list to create a 'summary' form and override the GetFieldsInfo method to tinker with the fileds collection returned. I recently wanted to apply this approach to a TypedView and noticed that the GetFieldsInfo method is not 'virtual'.

I know how to modify the TypedView template but I wanted to inquire about the rational behind not making the GetFieldsInfo method 'virtual' for TypedViews just in case there's something in that rational that renders the approach I've described above unusable in the TypedView context.

For a brief example of what I'd like to do in the typed view, code follows...

    public class PubCaseFineSummaryTypedView : PubCaseFineTypedView
    {
        public PubCaseFineSummaryTypedView()
        {
        }

        /* This currently isn't possible b/c GetFieldsInfo is not 'virtual' */
        public override IEntityFields2 GetFieldsInfo()
        {
            IEntityFields2 baseFields = base.GetFieldsInfo();
            EntityFields2 fields = new EntityFields2(4);

            fields.DefineField(
                baseFields[PubCaseFineTypedView.FieldNames.OwedAmount],
                0, 
                AggregateFunction.Sum
                );

            fields.DefineField(
                baseFields[PubCaseFineTypedView.FieldNames.CreditAmount],
                1, 
                AggregateFunction.Sum
                );

            fields.DefineField(
                baseFields[PubCaseFineTypedView.FieldNames.SuspendedAmount],
                2, 
                AggregateFunction.Sum
                );

            fields.DefineField(
                baseFields[PubCaseFineTypedView.FieldNames.PaidAmount],
                3, 
                AggregateFunction.Sum
                );
                    
            return fields;
        }   
    }
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39912
Joined: 17-Aug-2003
# Posted on: 14-Jun-2007 11:28:25   

The reason it's not virtual is that the typedview is mapped onto a fixed set of fields, namely the view fields simple_smile So we never thought of a use case to modify this field set to other needs, as the view itself wouldn't change (there's also not a relation building routine for example).

I can make the method virtual, no problem. It will be virtual in v2.5.

Frans Bouma | Lead developer LLBLGen Pro
everettm
User
Posts: 39
Joined: 17-Apr-2006
# Posted on: 14-Jun-2007 17:32:25   

Thanks for the explanation. I figured as much.

Is it fair to take your willingness to make this change to the template as a sign that you don't have any serious concerns about the approach?

As always, the support is top notch.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39912
Joined: 17-Aug-2003
# Posted on: 14-Jun-2007 20:27:28   

everettm wrote:

Thanks for the explanation. I figured as much.

Is it fair to take your willingness to make this change to the template as a sign that you don't have any serious concerns about the approach?

As always, the support is top notch.

simple_smile

There aren't concerns related to this, you can proceed with making it virtual, I've done so in the v2.5 templates (which will be released later today)

Frans Bouma | Lead developer LLBLGen Pro