typedlist error in llblgen v2.6

Posts   
 
    
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 23-Oct-2008 02:16:02   

llblgen 2.6 built 10/16/2008 dotnet 2.0

Hi My program was working flawlessly in llblgen 2.0. After I converted to llblgen 2.6 I got error. Below are the error message and source code (that I suspect where the error comes from). As you can see in the error message, the NumberOfError parameter seemed to get built wrongly in version 2.6 of llblgen.

Please advice. Thanks.

Error Message

The state information is invalid for this page and might be corrupted. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.

Source Error:

[No relevant source lines]

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\manageware4ajaxenabled.net\81530e96\439f50f8\App_Web_wzhl5yrr.10.cs Line: 0

Stack Trace:

[DuplicateNameException: A column named 'NumberOfErrors' already belongs to this DataTable.] System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column, DataTable table) +2020769 System.Data.DataColumnCollection.BaseAdd(DataColumn column) +79 System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column) +74 System.Data.DataColumnCollection.Add(DataColumn column) +8 MW.DAL.TypedListClasses.ClaimBillSummaryTypedList.OnInitialized() +91 MW.DAL.TypedListClasses.ClaimBillSummaryTypedList.InitMembers() +444 MW.DAL.TypedListClasses.ClaimBillSummaryTypedList..ctor(SerializationInfo info, StreamingContext context) +36

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context) +0 System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context) +24 System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context) +114 System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) +257 System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder) +49 System.Runtime.Serialization.ObjectManager.DoFixups() +167 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +203 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +190 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) +12 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +1669 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +854 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +854 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +198 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210 System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +198 System.Web.UI.ObjectStateFormatter.Deserialize(Stream inputStream) +142

[ArgumentException: The serialized data is invalid.] System.Web.UI.ObjectStateFormatter.Deserialize(Stream inputStream) +206 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +342 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4 System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37 System.Web.UI.HiddenFieldPageStatePersister.Load() +136

[ViewStateException: Invalid viewstate. Client IP: 127.0.0.1 Port: User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) ViewState:

VIEWSTATE REMOVED, the forum doesn't like looooooong lines -- Otis

[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.] System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +267 System.Web.UI.HiddenFieldPageStatePersister.Load() +218 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83 System.Web.UI.Page.LoadAllState() +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213 System.Web.UI.Page.ProcessRequest() +86 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18 System.Web.UI.Page.ProcessRequest(HttpContext context) +49 ASP.services_billreview_frm_frmclaimbilledit_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\manageware4ajaxenabled.net\81530e96\439f50f8\App_Web_wzhl5yrr.10.cs:0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

Suspected Source Code Where Error Originated From


using System.Text;
using SD.LLBLGen.Pro.ORMSupportClasses;
using MW.DAL.HelperClasses;
using System.Data;

namespace MW.DAL.TypedListClasses
{
    public partial class ClaimBillLineSummaryTypedList
    {
        #region Class Member Declarations
        private DataColumn _columnNumberOfLines;
        private DataColumn _columnNumberOfErrors;
        #endregion

        #region Class Property Declarations
        /// <summary>
        /// Gets the number of errors column.
        /// </summary>
        /// <value>The amount of errors column.</value>
        internal DataColumn NumberOfErrorsColumn
        {
            get { return _columnNumberOfErrors; }
        }
        #endregion

        /// <summary>
        /// Called when InitClass of the typedlist ended.
        /// </summary>
        protected override void OnInitialized()
        {
            _columnNumberOfLines = new DataColumn("NumberOfLines", typeof(int), null, MappingType.Element);
            _columnNumberOfLines.ReadOnly = true;
            this.Columns.Add(_columnNumberOfLines);

            _columnNumberOfErrors = new DataColumn("NumberOfErrors", typeof(int), null, MappingType.Element);
            _columnNumberOfErrors.ReadOnly = true;
            this.Columns.Add(_columnNumberOfErrors);
            base.OnInitialized();
        }

        /// <summary>
        /// Called when the typedlist's resultset has been build. This is the spot to add additional columns to the typedlist in code.
        /// We do this in code because we can't add a scalar query expression in the typedlist designer.
        /// </summary>
        /// <param name="fields">The typedlist resultset fields.</param>
        protected override void OnResultsetBuilt(IEntityFields2 fields)
        {
            // expand the fields with 3 slots, so we can add our scalar query expression to those slots
            int index = fields.Count;
            fields.Expand(1);

            // add a scalar query expression to the list of fields in the typedlist. The scalar query expression
            // performs a SELECT COUNT(id) FROM ClaimBillError WHERE claimbillerror.claimbillid = claimbill.ID query.
            fields.DefineField(new EntityField2("NumberOfErrors",
                                                new ScalarQueryExpression(ClaimBillLineErrorFields.Id.SetAggregateFunction(AggregateFunction.Count),
                                                                          (ClaimBillLineFields.Id == ClaimBillLineErrorFields.ClaimBillLineId))),
                               index++);

            // done
            base.OnResultsetBuilt(fields);
        }
    }
    public partial class ClaimBillLineSummaryRow
    {
        /// <summary>Gets / sets the value of the TypedList field NumberOfErrors<br/><br/>
        /// </summary>
        /// <remarks>Mapped on: the scalar query expression for retrieving the # of bils for each batch</remarks>
        public int NumberOfErrors
        {
            get
            {
                return (int)this[_parent.NumberOfErrorsColumn];
            }
        }
    }
}


daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Oct-2008 06:10:57   
David Elizondo | LLBLGen Support Team
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 23-Oct-2008 07:10:35   

Dang, I was so forgetful. I already ran into this problem and asked this question before!

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Oct-2008 07:57:38   

smile hehe. So I suppose that's solved. Back here if you run into troubles.

David Elizondo | LLBLGen Support Team
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 04-Nov-2008 09:07:35   

Daelmo

The trouble is solved. However I ran into another problem that I have no idea what the cause is. I suspect that the cause of the error has to do with llblgen v2.6

Here's the error detail

Error Message = "Object reference not set to an instance of an object."

Stack Trace = " at SD.LLBLGen.Pro.ORMSupportClasses.FieldUtilities.CreateDefaultValueForType(Type typeToCreateValueFor)\r\n at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateColumn(IFieldPersistenceInfo persistenceInfo, IEntityFieldCore sourceField)\r\n at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.ManglePageSelectDQ(IRetrievalQuery& selectQuery, IEntityFieldCore[] selectList, IFieldPersistenceInfo[] persistenceInfo, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateQueryFromElements(IEntityFields2 fieldCollectionToFetch, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize, IFieldPersistenceInfo[]& persistenceInfo, IRetrievalQuery& selectQuery)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(ITypedListLgp2 typedListToFill, IPredicateExpression additionalFilter, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, Int32 pageNumber, Int32 pageSize)\r\n at MW.BLL.BatchGuiHelper.GetBatchesSummary(PredicateExpression expression, Int32 pageNumber, Int32 pageSize) in C:\\projects\\mw4\\BLL\\BatchGuiHelper.cs:line 280\r\n at MW.BLL.BatchGuiHelper.GetBatchesSummarySimple(String batchNumber, Int32 status, String client, String employer, String user, Int32 pageNumber, Int32 pageSize) in C:\\projects\\mw4\\BLL\\BatchGuiHelper.cs:line 363\r\n at Services_BillReview_uc_ucBatch_Search.ldsBatches_PerformSelect(Object sender, PerformSelectEventArgs2 e) in c:\\projects\\mw4\\ManageWare4AJAXEnabled.net\\Services\\BillReview\\uc\\ucBatch_Search.ascx.cs:line 134\r\n at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource2.OnPerformSelect(PerformSelectEventArgs2 eventArgs)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelectTypedList(Int32 pageSize, Int32 pageNumber, DataSourceSelectArguments arguments)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelect(DataSourceSelectArguments arguments)\r\n at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)\r\n at System.Web.UI.WebControls.DataBoundControl.PerformSelect()\r\n at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()\r\n at System.Web.UI.WebControls.GridView.DataBind()\r\n at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()\r\n at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()\r\n at System.Web.UI.Control.EnsureChildControls()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Control.PreRenderRecursiveInternal()\r\n at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)"

Exception is thrown whenever the pageNumber is greater than 1. Note that when pageNumber equals 1 then there's no exception thrown.

adapter.FetchTypedList(results, expression, 0, null, false, pageNumber, pageSize);

And the designer generated TypedList and the extended properties are shown below:

/////////////////////////////////////////////////////////////// // This is generated code. ////////////////////////////////////////////////////////////// // Code is generated using LLBLGen Pro version: 2.6 // Code is generated on: Wednesday, October 22, 2008 4:12:26 PM // Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20 // Templates vendor: Solutions Design. // Templates version: ////////////////////////////////////////////////////////////// using System; using System.ComponentModel; using System.Data; using System.Collections;

if !CF

using System.Runtime.Serialization;

endif

using MW.DAL.EntityClasses; using MW.DAL.HelperClasses; using MW.DAL.FactoryClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MW.DAL.TypedListClasses {

// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
// __LLBLGENPRO_USER_CODE_REGION_END

/// <summary>
/// Typed datatable for the list 'BatchSummary'.<br/><br/>
/// 
/// </summary>
/// <remarks>
/// The code doesn't support any changing of data. Users who do that are on their own.
/// It also doesn't support any event throwing. This list should be used as a base for readonly databinding
/// or dataview construction.
/// </remarks>

if !CF

[Serializable, System.ComponentModel.DesignerCategory("Code")]
[ToolboxItem(true)]
[DesignTimeVisible(true)]

endif

public partial class BatchSummaryTypedList : TypedListBase2<BatchSummaryRow>, ITypedListLgp2
    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfacesList
    // __LLBLGENPRO_USER_CODE_REGION_END    
{
    #region Class Member Declarations
    private DataColumn _columnId;
    private DataColumn _columnBatchNumber;
    private DataColumn _columnBatchStatusName;
    private DataColumn _columnReceivedOn;
    private DataColumn _columnClientName;
    private DataColumn _columnEmployerName;
    private DataColumn _columnAspnetUsersUserName;
    private ResultsetFields _fields;
    private IRelationPredicateBucket _filterBucket;

    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalMembers
    // __LLBLGENPRO_USER_CODE_REGION_END
    private static Hashtable    _customProperties;
    private static Hashtable    _fieldsCustomProperties;
    #endregion

    #region Class Constants
    /// <summary>The amount of fields in the resultset.</summary>
    private const int AmountOfFields = 7;
    #endregion


    /// <summary>Static CTor for setting up custom property hashtables. Is executed before the first instance of this
    /// class or derived classes is constructed. </summary>
    static BatchSummaryTypedList()
    {
        SetupCustomPropertyHashtables();
    }


    /// <summary>CTor</summary>
    public BatchSummaryTypedList():base("BatchSummary")
    {
        InitClass(false);
    }


    /// <summary>CTor</summary>
    /// <param name="obeyWeakRelations">The flag to signal the collection what kind of join statements to generate in the
    /// query statement. Weak relationships are relationships which are optional, for example a
    /// customer with no orders is possible, because the relationship between customer and order is based on a field in order.
    /// When this property is set to true (default: false), weak relationships will result in LEFT JOIN statements. When
    /// set to false (which is the default), INNER JOIN statements are used.
    /// </param>
    public BatchSummaryTypedList(bool obeyWeakRelations):base("BatchSummary")
    {
        InitClass(obeyWeakRelations);
    }

if !CF

    /// <summary>Protected constructor for deserialization.</summary>
    /// <param name="info"></param>
    /// <param name="context"></param>
    protected BatchSummaryTypedList(SerializationInfo info, StreamingContext context):base(info, context)
    {
        if(SerializationHelper.Optimization == SerializationOptimization.None)
        {
            InitMembers();
            BuildResultset();
        }
    }

endif

    /// <summary>Gets the IEntityFields2 collection of fields of this typed list. Use this method in combination with the FetchTypedList() methods in 
    /// DataAccessAdapter.</summary>
    /// <returns>Ready to use IEntityFields2 collection object.</returns>
    public virtual IEntityFields2 GetFieldsInfo()
    {
        return _fields;
    }


    /// <summary>Gets the IRelationPredicateBucket object which contains the relation information for this Typed List. Use this method in combination with the 
    /// FetchTypedList() methods in DataAccessAdapter.</summary>
    /// <returns>Ready to use IRelationPredicateBucket object.</returns>
    public virtual IRelationPredicateBucket GetRelationInfo()
    {
        _filterBucket = new RelationPredicateBucket();
        BuildRelationSet();
        return _filterBucket;
    }

    /// <summary>Creates a new typed row during the build of the datatable during a Fill session by a dataadapter.</summary>
    /// <param name="rowBuilder">supplied row builder to pass to the typed row</param>
    /// <returns>the new typed datarow</returns>
    protected override DataRow NewRowFromBuilder(DataRowBuilder rowBuilder) 
    {
        return new BatchSummaryRow(rowBuilder);
    }


    /// <summary>Initializes the hashtables for the typed list type and typed list field custom properties. </summary>
    private static void SetupCustomPropertyHashtables()
    {
        _customProperties = new Hashtable();
        _fieldsCustomProperties = new Hashtable();

        Hashtable fieldHashtable = null;

        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("Id", fieldHashtable);
        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("BatchNumber", fieldHashtable);
        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("BatchStatusName", fieldHashtable);
        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("ReceivedOn", fieldHashtable);
        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("ClientName", fieldHashtable);
        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("EmployerName", fieldHashtable);
        fieldHashtable = new Hashtable();

        _fieldsCustomProperties.Add("AspnetUsersUserName", fieldHashtable);         
    }


    /// <summary>Builds the relation set for this typed list, inside the filterBucket object.</summary>
    private void BuildRelationSet()
    {
        _filterBucket.Relations.ObeyWeakRelations = base.ObeyWeakRelations;
        _filterBucket.Relations.Add(AspnetUsersEntity.Relations.BatchEntityUsingAspnetUsersUserid, "", "", JoinHint.Right);
        _filterBucket.Relations.Add(BatchEntity.Relations.BatchStatusEntityUsingStatus, "", "", JoinHint.Left);
        _filterBucket.Relations.Add(BatchEntity.Relations.ClientEntityUsingClientId, "", "", JoinHint.None);
        _filterBucket.Relations.Add(BatchEntity.Relations.EmployerEntityUsingEmployerId, "", "", JoinHint.Left);

        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalRelations
        // __LLBLGENPRO_USER_CODE_REGION_END
        OnRelationSetBuilt(_filterBucket.Relations);
    }


    /// <summary>Builds the resultset fields, stored in the private _fields object</summary>
    private void BuildResultset()
    {
        _fields = new ResultsetFields(AmountOfFields);
        _fields.DefineField(BatchFields.Id, 0, "Id", "", AggregateFunction.None);
        _fields.DefineField(BatchFields.BatchNumber, 1, "BatchNumber", "", AggregateFunction.None);
        _fields.DefineField(BatchStatusFields.Name, 2, "BatchStatusName", "", AggregateFunction.None);
        _fields.DefineField(BatchFields.ReceivedOn, 3, "ReceivedOn", "", AggregateFunction.None);
        _fields.DefineField(ClientFields.ClientName, 4, "ClientName", "", AggregateFunction.None);
        _fields.DefineField(EmployerFields.EmployerName, 5, "EmployerName", "", AggregateFunction.None);
        _fields.DefineField(AspnetUsersFields.UserName, 6, "AspnetUsersUserName", "", AggregateFunction.None);

        // __LLBLGENPRO_USER_CODE_REGION_START AdditionalFields
        // be sure to call _fields.Expand(number of new fields) first. 
        // __LLBLGENPRO_USER_CODE_REGION_END
        OnResultsetBuilt(_fields);
    }


    /// <summary>Initialize the datastructures.</summary>
    /// <param name="obeyWeakRelations">flag for the internal used relations object</param>
    protected override void InitClass(bool obeyWeakRelations)
    {
        TableName = "BatchSummary";     
        base.ObeyWeakRelations = obeyWeakRelations;

        _columnId = new DataColumn("Id", typeof(System.Int32), null, MappingType.Element);
        _columnId.ReadOnly = true;
        _columnId.Caption = @"Id";
        this.Columns.Add(_columnId);
        _columnBatchNumber = new DataColumn("BatchNumber", typeof(System.String), null, MappingType.Element);
        _columnBatchNumber.ReadOnly = true;
        _columnBatchNumber.Caption = @"BatchNumber";
        this.Columns.Add(_columnBatchNumber);
        _columnBatchStatusName = new DataColumn("BatchStatusName", typeof(System.String), null, MappingType.Element);
        _columnBatchStatusName.ReadOnly = true;
        _columnBatchStatusName.Caption = @"Name";
        this.Columns.Add(_columnBatchStatusName);
        _columnReceivedOn = new DataColumn("ReceivedOn", typeof(System.DateTime), null, MappingType.Element);
        _columnReceivedOn.ReadOnly = true;
        _columnReceivedOn.Caption = @"ReceivedOn";
        this.Columns.Add(_columnReceivedOn);
        _columnClientName = new DataColumn("ClientName", typeof(System.String), null, MappingType.Element);
        _columnClientName.ReadOnly = true;
        _columnClientName.Caption = @"ClientName";
        this.Columns.Add(_columnClientName);
        _columnEmployerName = new DataColumn("EmployerName", typeof(System.String), null, MappingType.Element);
        _columnEmployerName.ReadOnly = true;
        _columnEmployerName.Caption = @"EmployerName";
        this.Columns.Add(_columnEmployerName);
        _columnAspnetUsersUserName = new DataColumn("AspnetUsersUserName", typeof(System.String), null, MappingType.Element);
        _columnAspnetUsersUserName.ReadOnly = true;
        _columnAspnetUsersUserName.Caption = @"UserName";
        this.Columns.Add(_columnAspnetUsersUserName);

        // __LLBLGENPRO_USER_CODE_REGION_START InitClass
        // __LLBLGENPRO_USER_CODE_REGION_END

        BuildResultset();
        _filterBucket = new RelationPredicateBucket();
        BuildRelationSet();
        OnInitialized();
    }


    /// <summary>Initializes the members, after a clone action.</summary>
    private void InitMembers()
    {
        _columnId = this.Columns["Id"];
        _columnBatchNumber = this.Columns["BatchNumber"];
        _columnBatchStatusName = this.Columns["BatchStatusName"];
        _columnReceivedOn = this.Columns["ReceivedOn"];
        _columnClientName = this.Columns["ClientName"];
        _columnEmployerName = this.Columns["EmployerName"];
        _columnAspnetUsersUserName = this.Columns["AspnetUsersUserName"];

        // __LLBLGENPRO_USER_CODE_REGION_START InitMembers
        // __LLBLGENPRO_USER_CODE_REGION_END
        OnInitialized();
    }


    /// <summary>Return the type of the typed datarow</summary>
    /// <returns>returns the requested type</returns>
    protected override Type GetRowType() 
    {
        return typeof(BatchSummaryRow);
    }


    /// <summary>Clones this instance.</summary>
    /// <returns>A clone of this instance</returns>
    public override DataTable Clone() 
    {
        BatchSummaryTypedList cloneToReturn = ((BatchSummaryTypedList)(base.Clone()));
        cloneToReturn.InitMembers();
        return cloneToReturn;
    }

if !CF

    /// <summary>Creates a new instance of the DataTable class.</summary>
    /// <returns>a new instance of a datatable with this schema.</returns>
    protected override DataTable CreateInstance() 
    {
        return new BatchSummaryTypedList();
    }

endif

    #region Class Property Declarations
    /// <summary>Returns the amount of rows in this typed list.</summary>
    [System.ComponentModel.Browsable(false)]
    public override int Count 
    {
        get 
        {
            return this.Rows.Count;
        }
    }

    /// <summary>The custom properties for this TypedList type.</summary>
    /// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
    public static Hashtable CustomProperties
    {
        get { return _customProperties;}
    }

    /// <summary>The custom properties for the type of this TypedList instance.</summary>
    /// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
    [System.ComponentModel.Browsable(false)]
    public virtual Hashtable CustomPropertiesOfType
    {
        get { return BatchSummaryTypedList.CustomProperties;}
    }

    /// <summary>The custom properties for the fields of this TypedList type. The returned Hashtable contains per fieldname a hashtable of name-value
    /// pairs. </summary>
    /// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
    public static Hashtable FieldsCustomProperties
    {
        get { return _fieldsCustomProperties;}
    }

    /// <summary>The custom properties for the fields of the type of this TypedList instance. The returned Hashtable contains per fieldname a hashtable of name-value
    /// pairs. </summary>
    /// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
    [System.ComponentModel.Browsable(false)]
    public virtual Hashtable FieldsCustomPropertiesOfType
    {
        get { return BatchSummaryTypedList.FieldsCustomProperties;}
    }

    /// <summary>Indexer of this strong typed list</summary>
    public BatchSummaryRow this[int index] 
    {
        get 
        {
            return ((BatchSummaryRow)(this.Rows[index]));
        }
    }

    /// <summary>Gets an array of all BatchSummaryRow objects.</summary>
    /// <returns>Array with BatchSummaryRow objects</returns>
    public new BatchSummaryRow[] Select()
    {
        return (BatchSummaryRow[])base.Select();
    }


    /// <summary>Gets an array of all BatchSummaryRow objects that match the filter criteria in order of primary key (or lacking one, order of addition.) </summary>
    /// <param name="filterExpression">The criteria to use to filter the rows.</param>
    /// <returns>Array with BatchSummaryRow objects</returns>
    public new BatchSummaryRow[] Select(string filterExpression)
    {
        return (BatchSummaryRow[])base.Select(filterExpression);
    }


    /// <summary>Gets an array of all BatchSummaryRow objects that match the filter criteria, in the specified sort order</summary>
    /// <param name="filterExpression">The filter expression.</param>
    /// <param name="sort">A string specifying the column and sort direction.</param>
    /// <returns>Array with BatchSummaryRow objects</returns>
    public new BatchSummaryRow[] Select(string filterExpression, string sort)
    {
        return (BatchSummaryRow[])base.Select(filterExpression, sort);
    }


    /// <summary>Gets an array of all BatchSummaryRow objects that match the filter criteria, in the specified sort order that match the specified state</summary>
    /// <param name="filterExpression">The filter expression.</param>
    /// <param name="sort">A string specifying the column and sort direction.</param>
    /// <param name="recordStates">One of the <see cref="System.Data.DataViewRowState"/> values.</param>
    /// <returns>Array with BatchSummaryRow objects</returns>
    public new BatchSummaryRow[] Select(string filterExpression, string sort, DataViewRowState recordStates)
    {
        return (BatchSummaryRow[])base.Select(filterExpression, sort, recordStates);
    }


    /// <summary>Returns the column object belonging to the TypedList field Id</summary>
    internal DataColumn IdColumn 
    {
        get { return _columnId; }
    }

    /// <summary>Returns the column object belonging to the TypedList field BatchNumber</summary>
    internal DataColumn BatchNumberColumn 
    {
        get { return _columnBatchNumber; }
    }

    /// <summary>Returns the column object belonging to the TypedList field BatchStatusName</summary>
    internal DataColumn BatchStatusNameColumn 
    {
        get { return _columnBatchStatusName; }
    }

    /// <summary>Returns the column object belonging to the TypedList field ReceivedOn</summary>
    internal DataColumn ReceivedOnColumn 
    {
        get { return _columnReceivedOn; }
    }

    /// <summary>Returns the column object belonging to the TypedList field ClientName</summary>
    internal DataColumn ClientNameColumn 
    {
        get { return _columnClientName; }
    }

    /// <summary>Returns the column object belonging to the TypedList field EmployerName</summary>
    internal DataColumn EmployerNameColumn 
    {
        get { return _columnEmployerName; }
    }

    /// <summary>Returns the column object belonging to the TypedList field AspnetUsersUserName</summary>
    internal DataColumn AspnetUsersUserNameColumn 
    {
        get { return _columnAspnetUsersUserName; }
    }


    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalColumnProperties
    // __LLBLGENPRO_USER_CODE_REGION_END
    #endregion

    #region Custom TypedList code

    // __LLBLGENPRO_USER_CODE_REGION_START CustomTypedListCode
    // __LLBLGENPRO_USER_CODE_REGION_END
    #endregion

    #region Included Code

    #endregion
}


/// <summary>
/// Typed datarow for the typed datatable BatchSummary
/// </summary>
public partial class BatchSummaryRow : DataRow
    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfacesRow
    // __LLBLGENPRO_USER_CODE_REGION_END    
{
    #region Class Member Declarations
    private BatchSummaryTypedList   _parent;
    #endregion

    /// <summary>CTor</summary>
    /// <param name="rowBuilder">Row builder object to use when building this row</param>
    protected internal BatchSummaryRow(DataRowBuilder rowBuilder) : base(rowBuilder) 
    {
        _parent = ((BatchSummaryTypedList)(this.Table));
    }


    #region Class Property Declarations

    /// <summary>Gets / sets the value of the TypedList field Id<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: Batch.Id</remarks>
    public System.Int32 Id 
    {
        get 
        {
            if(IsIdNull())
            {
                return (System.Int32)TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
            }
            else
            {
                return (System.Int32)this[_parent.IdColumn];
            }
        }
        set 
        {
            this[_parent.IdColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field Id is NULL, false otherwise.</summary>
    public bool IsIdNull() 
    {
        return IsNull(_parent.IdColumn);
    }

    /// <summary>Sets the TypedList field Id to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetIdNull() 
    {
        this[_parent.IdColumn] = System.Convert.DBNull;
    }



    /// <summary>Gets / sets the value of the TypedList field BatchNumber<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: Batch.BatchNumber</remarks>
    public System.String BatchNumber 
    {
        get 
        {
            if(IsBatchNumberNull())
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
            else
            {
                return (System.String)this[_parent.BatchNumberColumn];
            }
        }
        set 
        {
            this[_parent.BatchNumberColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field BatchNumber is NULL, false otherwise.</summary>
    public bool IsBatchNumberNull() 
    {
        return IsNull(_parent.BatchNumberColumn);
    }

    /// <summary>Sets the TypedList field BatchNumber to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetBatchNumberNull() 
    {
        this[_parent.BatchNumberColumn] = System.Convert.DBNull;
    }



    /// <summary>Gets / sets the value of the TypedList field BatchStatusName<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: BatchStatus.Name</remarks>
    public System.String BatchStatusName 
    {
        get 
        {
            if(IsBatchStatusNameNull())
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
            else
            {
                return (System.String)this[_parent.BatchStatusNameColumn];
            }
        }
        set 
        {
            this[_parent.BatchStatusNameColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field BatchStatusName is NULL, false otherwise.</summary>
    public bool IsBatchStatusNameNull() 
    {
        return IsNull(_parent.BatchStatusNameColumn);
    }

    /// <summary>Sets the TypedList field BatchStatusName to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetBatchStatusNameNull() 
    {
        this[_parent.BatchStatusNameColumn] = System.Convert.DBNull;
    }



    /// <summary>Gets / sets the value of the TypedList field ReceivedOn<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: Batch.ReceivedOn</remarks>
    public System.DateTime ReceivedOn 
    {
        get 
        {
            if(IsReceivedOnNull())
            {
                return (System.DateTime)TypeDefaultValue.GetDefaultValue(typeof(System.DateTime));
            }
            else
            {
                return (System.DateTime)this[_parent.ReceivedOnColumn];
            }
        }
        set 
        {
            this[_parent.ReceivedOnColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field ReceivedOn is NULL, false otherwise.</summary>
    public bool IsReceivedOnNull() 
    {
        return IsNull(_parent.ReceivedOnColumn);
    }

    /// <summary>Sets the TypedList field ReceivedOn to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetReceivedOnNull() 
    {
        this[_parent.ReceivedOnColumn] = System.Convert.DBNull;
    }



    /// <summary>Gets / sets the value of the TypedList field ClientName<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: Client.ClientName</remarks>
    public System.String ClientName 
    {
        get 
        {
            if(IsClientNameNull())
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
            else
            {
                return (System.String)this[_parent.ClientNameColumn];
            }
        }
        set 
        {
            this[_parent.ClientNameColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field ClientName is NULL, false otherwise.</summary>
    public bool IsClientNameNull() 
    {
        return IsNull(_parent.ClientNameColumn);
    }

    /// <summary>Sets the TypedList field ClientName to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetClientNameNull() 
    {
        this[_parent.ClientNameColumn] = System.Convert.DBNull;
    }



    /// <summary>Gets / sets the value of the TypedList field EmployerName<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: Employer.EmployerName</remarks>
    public System.String EmployerName 
    {
        get 
        {
            if(IsEmployerNameNull())
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
            else
            {
                return (System.String)this[_parent.EmployerNameColumn];
            }
        }
        set 
        {
            this[_parent.EmployerNameColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field EmployerName is NULL, false otherwise.</summary>
    public bool IsEmployerNameNull() 
    {
        return IsNull(_parent.EmployerNameColumn);
    }

    /// <summary>Sets the TypedList field EmployerName to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetEmployerNameNull() 
    {
        this[_parent.EmployerNameColumn] = System.Convert.DBNull;
    }



    /// <summary>Gets / sets the value of the TypedList field AspnetUsersUserName<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: AspnetUsers.UserName</remarks>
    public System.String AspnetUsersUserName 
    {
        get 
        {
            if(IsAspnetUsersUserNameNull())
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
            else
            {
                return (System.String)this[_parent.AspnetUsersUserNameColumn];
            }
        }
        set 
        {
            this[_parent.AspnetUsersUserNameColumn] = value;
        }
    }

    /// <summary>Returns true if the TypedList field AspnetUsersUserName is NULL, false otherwise.</summary>
    public bool IsAspnetUsersUserNameNull() 
    {
        return IsNull(_parent.AspnetUsersUserNameColumn);
    }

    /// <summary>Sets the TypedList field AspnetUsersUserName to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
    public void SetAspnetUsersUserNameNull() 
    {
        this[_parent.AspnetUsersUserNameColumn] = System.Convert.DBNull;
    }


    #endregion

    #region Custom Typed List Row Code

    // __LLBLGENPRO_USER_CODE_REGION_START CustomTypedListRowCode
    // __LLBLGENPRO_USER_CODE_REGION_END
    #endregion
}

}

using System; using System.Collections.Generic; using System.Text; using SD.LLBLGen.Pro.ORMSupportClasses; using MW.DAL.HelperClasses; using MW.DAL.EntityClasses; using System.Data;

namespace MW.DAL.TypedListClasses {

/// <summary>
/// Extension class which extends the typedlist BatchSummaryTypedList and adds a scalar query expression column to the typedlist.
/// This code is derived from: [http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8110](http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8110)
/// </summary>
public partial class BatchSummaryTypedList
{
    #region Class Member Declarations
    private DataColumn _columnNumberOfBills;
    //private DataColumn _columnNumberOfBillsWithError;
    //private DataColumn _columnNumberOfBillsWithLineError;
    #endregion

    #region Class Property Declarations
    /// <summary>
    /// Gets the amount of bills column.
    /// </summary>
    /// <value>The amount of bills column.</value>
    internal DataColumn NumberOfBillsColumn
    {
        get { return _columnNumberOfBills; }
    }
    /// <summary>
    /// Gets the amount of bills-with-error column.
    /// </summary>
    /// <value>The amount of bills-with-error column.</value>
    //internal DataColumn NumberOfBillsWithErrorColumn
    //{
    //  get { return _columnNumberOfBillsWithError; }
    //}
    /// <summary>
    /// Gets the amount of bills-with-line_error column.
    /// </summary>
    /// <value>The amount of bills-with-line_error column.</value>
    //internal DataColumn NumberOfBillsWithLineErrorColumn
    //{
    //  get { return _columnNumberOfBillsWithLineError; }
    //}
    #endregion

    /// <summary>
    /// Called when InitClass of the typedlist ended.
    /// </summary>
    protected override void OnInitialized()
    {
        _columnNumberOfBills = this.Columns["NumberOfBills"];
        if (_columnNumberOfBills == null)
        {
            _columnNumberOfBills = new DataColumn("NumberOfBills", typeof(int), null, MappingType.Element);
            _columnNumberOfBills.ReadOnly = true;
            this.Columns.Add(_columnNumberOfBills);
        }

        //_columnNumberOfBillsWithError = this.Columns["NumberOfBillsWithError"];
        //if (_columnNumberOfBillsWithError == null)
        //{
        //  _columnNumberOfBillsWithError = new DataColumn("NumberOfBillsWithError", typeof(int), null, MappingType.Element);
        //  _columnNumberOfBillsWithError.ReadOnly = true;
        //  this.Columns.Add(_columnNumberOfBillsWithError);
        //}

        //_columnNumberOfBillsWithLineError = this.Columns["NumberOfBillsWithLineError"];
        //if (_columnNumberOfBillsWithLineError == null)
        //{
        //  _columnNumberOfBillsWithLineError = new DataColumn("NumberOfBillsWithLineError", typeof(int), null, MappingType.Element);
        //  _columnNumberOfBillsWithLineError.ReadOnly = true;
        //  this.Columns.Add(_columnNumberOfBillsWithLineError);
        //}
        base.OnInitialized();
    }

    /// <summary>
    /// Called when the typedlist's resultset has been build. This is the spot to add additional columns to the typedlist in code.
    /// We do this in code because we can't add a scalar query expression in the typedlist designer.
    /// </summary>
    /// <param name="fields">The typedlist resultset fields.</param>
    protected override void OnResultsetBuilt(IEntityFields2 fields)
    {
        //// expand the fields with 2 slots, so we can add our scalar query expression to those slots
        int index = fields.Count;
        fields.Expand(1);

        // add a scalar query expression to the list of fields in the typedlist. The scalar query expression
        // performs a SELECT COUNT(ClaimBill) FROM ClaimBill WHERE BatchId = Batch.ID_ query.
        // (note that we use ClaimBillFields.BatchId_ cuz this corresponds to Batch_ID in the table instead of the legacy BatchID field).
        fields.DefineField(new EntityField2("NumberOfBills",
                                            new ScalarQueryExpression(ClaimBillFields.Id.SetAggregateFunction(AggregateFunction.Count),
                                                                      (BatchFields.Id == ClaimBillFields.BatchId_))),
                           index++);
        //// add a scalar query expression to the list of fields in the typedlist. The scalar query expression
        //// performs the query:
        //// [ 
        ////   SELECT COUNT(distinct Claim_Bill.Id ) FROM Claim_Bill 
        ////   INNER JOIN Claim_Bill_Error ON Claim_Bill_Error.Claim_Bill_Id = Claim_Bill.Id
        ////   WHERE Batch.ID = batchid
        //// ]
        //IRelationCollection relations = new RelationCollection();
        //relations.Add(ClaimBillEntity.Relations.ClaimBillErrorEntityUsingClaimBillId);

        //fields.DefineField(new EntityField2("NumberOfBillsWithError",
        //                                  new ScalarQueryExpression(ClaimBillFields.Id.SetAggregateFunction(AggregateFunction.CountDistinct),
        //                                                           BatchFields.Id == ClaimBillFields.BatchId_,
        //                                                           relations
        //                                                           )
        //                                  ),
        //                  index++);
        //// add a scalar query expression to the list of fields in the typedlist. The scalar query expression
        //// performs the query:
        //// [ 
        ////   SELECT COUNT(distinct Claim_Bill.Id ) FROM Claim_Bill 
        ////   INNER JOIN Claim_Bill_Line ON Claim_Bill_Line.Claim_Bill_Id = Claim_Bill.Id
        ////   INNER JOIN Claim_Bill_Line_Error ON Claim_Bill_Line.Id = Claim_Bill_Line_Error.Claim_Bill_Line_Id
        ////   WHERE Batch.ID = batchid
        //// ]
        //IRelationCollection relations2 = new RelationCollection();
        //relations2.Add(ClaimBillEntity.Relations.ClaimBillLineEntityUsingClaimId);
        //relations2.Add(ClaimBillLineEntity.Relations.ClaimBillLineErrorEntityUsingClaimBillLineId);

        //fields.DefineField(new EntityField2("NumberOfBillsWithLineError",
        //                                  new ScalarQueryExpression(ClaimBillFields.Id.SetAggregateFunction(AggregateFunction.CountDistinct),
        //                                                           BatchFields.Id == ClaimBillFields.BatchId_,
        //                                                           relations2
        //                                                           )
        //                                  ),
        //                  index++);
        //// done
        base.OnResultsetBuilt(fields);
    }
}

/// <summary>
/// Extension class for the row class of the MessagesInThread typedlist.
/// </summary>
public partial class BatchSummaryRow
{
    /// <summary>Gets / sets the value of the TypedList field NumberOfBills<br/><br/>
    /// </summary>
    /// <remarks>Mapped on: the scalar query expression for retrieving the # of bills for each batch</remarks>
    public int NumberOfBills
    {
        get
        {
            return (int)this[_parent.NumberOfBillsColumn];
        }
    }
    ///// <summary>Gets / sets the value of the TypedList field NumberOfBillsWithError<br/><br/>
    ///// </summary>
    ///// <remarks>Mapped on: the scalar query expression for retrieving the # of bills-with-error for each batch</remarks>
    //public int NumberOfBillsWithError
    //{
    //  get
    //  {
    //      return (int)this[_parent.NumberOfBillsWithErrorColumn];
    //  }
    //}
    ///// <summary>Gets / sets the value of the TypedList field NumberOfBillsWithLineError<br/><br/>
    ///// </summary>
    ///// <remarks>Mapped on: the scalar query expression for retrieving the # of bills-with-line-error for each batch</remarks>
    //public int NumberOfBillsWithLineError
    //{
    //  get
    //  {
    //      return (int)this[_parent.NumberOfBillsWithLineErrorColumn];
    //  }
    //}
}

}

Please note also that if the extended property of the typed is is all commented out then the problem goes away.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 04-Nov-2008 10:49:37   

Please attach the code files rather then posting it inside the message body, I find it very hard to traverse your code.

Also I see many commented lines, would you please remove them out.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 04-Nov-2008 10:58:25   

I think it's this:


fields.DefineField(new EntityField2("NumberOfBills",
                                                new ScalarQueryExpression(ClaimBillFields.Id.SetAggregateFunction(AggregateFunction.Count),
                                                                         (BatchFields.Id == ClaimBillFields.BatchId_))),
                             index++);

Please use the EntityField2() ctor overload which accepts a Type object and try again.

Frans Bouma | Lead developer LLBLGen Pro
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 04-Nov-2008 18:11:13   

OK, I will clean up the source code and will attach it in soon.

Otis, You were right on the money. It works. Could you please explain why llblgen v2.6 requires the datatype specified?

Thank you

BZ

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 04-Nov-2008 18:38:01   

In projections and other areas where the returnvalue of the scalar is needed, the type of the return value can't be determined in the .NET code, as it is unknown what value is returned from the scalar / aggregate / expression. So we needed the type to be specified as well. In previous versions this went wrong in some cases, hence the requirement.

Frans Bouma | Lead developer LLBLGen Pro