CodeSmith Community
Your Code. Your Way. Faster!

How? DataSet to TList or DataSet to VList

Latest post 06-20-2008 10:17 AM by rhettc. 2 replies.
  • 06-19-2008 6:07 AM

    • halex
    • Top 500 Contributor
    • Joined on 12-06-2006
    • Posts 14
    • Points 250

    How? DataSet to TList or DataSet to VList

    I found a lot of posts about problem for converting TList to DataSet but how I can convert DataSet to TList and VList in order to use generated classes I am used to?

    Thank in advance
    Alex

    • Post Points: 65
  • 06-19-2008 12:58 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 408
    • Points 10,290

    Re: How? DataSet to TList or DataSet to VList

    Besides the not so fun way, you would just manuall code it.  Loop through the rows, create a new Entity, add it to a list.  This is a very non generic way of doing this.

    You could try and write a generic function that used Reflection to get all the Properties of the Entity, loop through them, and see if there is a column in the Dataset that is named the same.  Then you could pass the Entity type and the dataset into the function and dynamically create the TList or VList.  Not sure how you would do relationships in the dataset.  If they were named the same as the child entity, you could try and do the same thing recursevely.

    I just don't know if there is any code in Nettiers that does this.  We just go the other way, Nettiers to Dataset.

    jeff

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 5
  • 06-20-2008 10:17 AM In reply to

    • rhettc
    • Top 150 Contributor
    • Joined on 05-02-2007
    • Posts 28
    • Points 666

    Re: How? DataSet to TList or DataSet to VList

    I don't know what your requirements are but if you are working with custom stored procedures, then may I suggest you use a DataReader as a custom non matching return type.  If that does not apply then maybe you can use the DataSet's CreateDataReader method.  If you have a DataReader then you can call the Fill method on the Provider classes to return a T-List.

    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems