TypedList Calculated fields error

Posts   
 
    
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 05-Jun-2013 17:34:30   

v 4.0 May 15th, 2013 I have a TypedList with two calculated fields. Used to work properly in v.3.5 Should I change anything


public partial class VentasTotalesPorProductoTypedList
{
            // new column
        DataColumn _columnTotal;
        DataColumn _columnTotalDiscount;
        protected override void OnResultsetBuilt(IEntityFields fields)
        {
            // expand fields and define the new ones
            fields.Expand(2);
            fields.DefineField(new EntityField(
                "Total",
                OrderDetailFields.Quantity * OrderDetailFields.UnitPrice * (1 - OrderDetailFields.Discount),
                AggregateFunction.Sum,
                typeof(System.Decimal)
                ), fields.Count - 2);
            fields.DefineField(new EntityField(
                "TotalDiscount",
                OrderDetailFields.Quantity * OrderDetailFields.UnitPrice * OrderDetailFields.Discount,
                AggregateFunction.Sum,
                typeof(System.Decimal)
                ), fields.Count - 1);
            base.OnResultsetBuilt(fields);
        }
...
}

The field.Expand(2) line gives an error, because _fieldPersistenceInfos is null SD.LLBLGen.Pro.ORMSupportClasses.EntityFields Expand method:

public override void Expand(int numberOfNewCells)
{
    base.Expand(numberOfNewCells);
    Array.Resize(ref _fieldPersistenceInfos, _fieldPersistenceInfos.Length + numberOfNewCells);
}

TIA

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Jun-2013 18:03:23   

You use the latest runtime build? Or do you use the may 15th runtime build?

Frans Bouma | Lead developer LLBLGen Pro
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 05-Jun-2013 18:27:25   

Tried with lastest build (27th may) just downloaded. Same error

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Jun-2013 19:08:56   

Could you please post the exception text and stack trace?

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 06-Jun-2013 12:07:08   

// System.NullReferenceException in EntityFields.Expand (_fieldPersistenceInfos == null)


// ASP.Net calling code:
Northwind.TypedListClasses.VentasTotalesPorProductoTypedList tl = new VentasTotalesPorProductoTypedList();
>tl.Fill(20, null);

// Calling code on VentasTotalesPorProductoTypedList.OnResultsetBuilt:
Línea 41:       {
Línea 42:           // expand fields and define the new ones
>Línea 43:          fields.Expand(2);
Línea 44:           fields.DefineField(new EntityField(
Línea 45:               "Total",

Stack trace:


[NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.]
   SD.LLBLGen.Pro.ORMSupportClasses.EntityFields.Expand(Int32 numberOfNewCells) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityFields.cs:199
   Northwind.TypedListClasses.VentasTotalesPorProductoTypedList.OnResultsetBuilt(IEntityFields fields) in D:\tmp\N23_Sort\ExtendedClasses\Extended_TypedList.cs:43
   Northwind.TypedListClasses.VentasTotalesPorProductoTypedList.BuildResultset() in D:\tmp\N23_Sort\TypedListClasses\VentasTotalesPorProductoTypedList.cs:131
   SD.LLBLGen.Pro.ORMSupportClasses.TypedListBase`1.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IPredicate selectFilter, ITransaction transactionToUse, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\TypedListBase.cs:173
   SD.LLBLGen.Pro.ORMSupportClasses.TypedListBase`1.Fill(Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\TypedListBase.cs:105
   ListControl.GridLoaded(Object sender, EventArgs e) in D:\tmp\N23_Sort\GUI\BaseControls\ListControl.cs:199

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 06-Jun-2013 12:22:04   

Attached Northwind project with the TypedList All the new code (OnResultsetBuilt, etc. in ExtendedClasses dir)

Attachments
Filename File size Added on Approval
typedListBug.7z 32,818 06-Jun-2013 12:22.13 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 06-Jun-2013 14:25:10   

We'll look into it!

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 06-Jun-2013 14:55:59   

Fixed in next build. Will be up in less than an hour.

Frans Bouma | Lead developer LLBLGen Pro
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 06-Jun-2013 17:53:16   

Tested. And once again... solved!!!

Thanks