Dynamic List

Posts   
 
    
Posts: 12
Joined: 30-Nov-2007
# Posted on: 03-Dec-2007 06:48:01   

HI, I don't know how to search the answer in history. So I post my question about "Dynamic List " again. below is my code:

      SelfServicing.HelperClasses.ResultsetFields fields = new SelfServicing.HelperClasses.ResultsetFields(5);
      fields.DefineField(SelfServicing.HelperClasses.ScFields.ScNo, 0, "ScNo");
      fields.DefineField(SelfServicing.HelperClasses.ScFields.ScDate, 1, "ScDate");
      fields.DefineField(SelfServicing.HelperClasses.ScItemFields.ItemNo, 2, "ScItemNo");
      fields.DefineField(SelfServicing.HelperClasses.ScItemFields.Qty, 3, "ScItemQty");
      fields.DefineField(SelfServicing.HelperClasses.ScItemFields.Price, 4, "ScItemPrice");

      IRelationCollection relations = new RelationCollection();
      relations.Add(ScItemEntity.Relations.ScEntityUsingScNo, "ScItem", "Sc", JoinHint.None);
    
      DataTable dynamicList = new DataTable();
      TypedListDAO dao = new TypedListDAO();
      dao.GetMultiAsDataTable(fields, dynamicList, 0, null, null, relations, true, null, null, 0, 0);

and there are 2 tables named Sc and ScItem in Database. and forieign Key in Sc.ScNo and ScItem.ScNo but, when I debug these code, there is a exception : ArgumentOutofRangeException where should I fix the code?

Thanks a lot again....

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Dec-2007 07:59:54   

No need to use aliases in the relation defined, since you don't use these aliases in the defined fields.

So instead of:

 relations.Add(ScItemEntity.Relations.ScEntityUsingScNo, "ScItem", "Sc", JoinHint.None);

Please try:

     relations.Add(ScItemEntity.Relations.ScEntityUsingScNo);
Posts: 12
Joined: 30-Nov-2007
# Posted on: 03-Dec-2007 08:16:08   

I'm sorry but there is the same error message. May I upload any for you to help me to finish this test, thank you.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Dec-2007 08:32:14   

Would you please the complete exception error and the stack trace? And the llblgen pro runtime library buildnr? (see: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7725 )

Posts: 12
Joined: 30-Nov-2007
# Posted on: 04-Dec-2007 02:29:22   

this is the exception and the stack and I use LLBLGen Pro 2.5 thanks for your help!!

   ? System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   ? System.ThrowHelper.ThrowArgumentOutOfRangeException()
   ? SD.LLBLGen.Pro.ORMSupportClasses.RelationCollection.ToQueryText(Int32& uniqueMarker)
   ? SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified)
   ? SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause)
   ? 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)
   ? SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.CreateQueryFromElements(ITransaction transactionToUse, IEntityFields fields, IPredicate filter, IRelationCollection relations, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IGroupByCollection groupByClause, Boolean allowDuplicates, Int32 pageNumber, Int32 pageSize)
   ? SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAsDataTableAction(IEntityFields fieldsToReturn, DataTable tableToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Boolean allowDuplicates, IGroupByCollection groupByClause, ITransaction transactionToUse, Int32 pageNumber, Int32 pageSize)
   ? SelfServicing.DaoClasses.TypedListDAO.GetMultiAsDataTable(IEntityFields fieldsToReturn, DataTable tableToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, Boolean allowDuplicates, IGroupByCollection groupByClause, ITransaction transactionToUse, Int32 pageNumber, Int32 pageSize) ? C:\Documents and Settings\vin\My Documents\Visual Studio 2005\Projects\LLBLProDemo\LLBLProDemo\DaoClasses\TypedListDAO.cs: ? 49
   ? LLBLProDemo.Form1.button2_Click(Object sender, EventArgs e) ? C:\Documents and Settings\vin\My Documents\Visual Studio 2005\Projects\LLBLProDemo\LLBLProDemo\Form1.cs: ? 58
   ? System.Windows.Forms.Control.OnClick(EventArgs e)
   ? System.Windows.Forms.Button.OnClick(EventArgs e)
   ? System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   ? System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   ? System.Windows.Forms.Control.WndProc(Message& m)
   ? System.Windows.Forms.ButtonBase.WndProc(Message& m)
   ? System.Windows.Forms.Button.WndProc(Message& m)
   ? System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   ? System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   ? System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 04-Dec-2007 14:26:39   

Odd, our tests which look similar to your code succeed.

Could you paste the Exact code you have which gives that exception? Also, are any of these entities in an inheritance hierarchy and if so, what's the hierarchy type? Please provide as much info as possible so we can try to reproduce it.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 12
Joined: 30-Nov-2007
# Posted on: 05-Dec-2007 06:36:46   

this is my code:

    private void button2_Click(object sender, EventArgs e)
    {
      SelfServicing.HelperClasses.ResultsetFields fields = new SelfServicing.HelperClasses.ResultsetFields(5);
      fields.DefineField(SelfServicing.HelperClasses.ScFields.ScNo, 0, "ScNo");
      fields.DefineField(SelfServicing.HelperClasses.ScFields.ScDate, 1, "ScDate");
      fields.DefineField(SelfServicing.HelperClasses.ScItemFields.ItemNo, 2, "ItemNo");
      fields.DefineField(SelfServicing.HelperClasses.ScItemFields.Qty, 3, "Qty");
      fields.DefineField(SelfServicing.HelperClasses.ScItemFields.Price, 4, "Price");

      IRelationCollection relations = new RelationCollection();
      relations.Add(ScItemEntity.Relations.ScEntityUsingScNo);
    
      //
      DbUtils.ActualConnectionString = "data source=vincent1974;initial catalog=BC_2006;User ID=sa;Password=123456;persist security info=False;packet size=4096";
      DataTable dynamicList = new DataTable();
      TypedListDAO dao = new TypedListDAO();
      dao.GetMultiAsDataTable(fields, dynamicList, 0, null, null, relations, true, null, null, 0, 0);
      MessageBox.Show(dynamicList.Rows.Count.ToString());
    }
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Dec-2007 10:32:24   

Please answer the following question:

Frans wrote:

Also, are any of these entities in an inheritance hierarchy and if so, what's the hierarchy type? Please provide as much info as possible so we can try to reproduce it.