in

CodeSmith Community

Your Code. Your Way. Faster!

Collections in TList

Last post 10-16-2006 5:09 AM by hkraft. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-13-2006 9:13 AM

    • hkraft
    • Not Ranked
    • Joined on 10-13-2006
    • Posts 3
    • Points 45

    Collections in TList

    An Ad is connected to a TradeCodeId in the database. So in the AdProvider its possible to select all Ads for a given tradecode, when listing TradeCodes i dont want to print the TradeCodes that arent in use, so i was thinking i could use the AdCollection of the TradeCode object, how do I make this happend? But the AdCollection.Count is always 0, so nothing is printed.

    An Ad is connected to a TradeCodeId in the database. So in the AdProvider its possible to select all Ads for a given tradecode, when listing TradeCodes i dont want to print the TradeCodes that arent in use, so i was thinking i could use the AdCollection of the TradeCode object, how do I make this happend? But the AdCollection.Count is always 0, so nothing is printed.

    Any thoughts?

    See code below

    TradeCodeDataSource s = new TradeCodeDataSource();
    s.Parameters.Add("CategoryID", CategoryID.ToString());
     s.SelectMethod = TradeCodeSelectMethod.GetByCategoryID;
    TList<TradeCode> tr = (TList<TradeCode>)s.GetEntityList();
    TList<TradeCode> List = new TList<TradeCode>();

    foreach (TradeCode tc in tr)
    {if (tc.AdCollection.Count > 0){List.Add(tc);}}

    • Post Points: 35
  • 10-13-2006 11:24 AM In reply to

    • Evan
    • Top 150 Contributor
    • Joined on 09-19-2006
    • Seattle, WA
    • Posts 30
    • Points 820

    Re: Collections in TList

    Hi,

    You'll need to DeepLoad your TradeCodeDataSource:

        TradeCodeDataSource s = new TradeCodeDataSource();
        s.DeepLoad();

    That should do the trick.

    Cheers,

    Evan 

     

     

    • Post Points: 35
  • 10-16-2006 5:09 AM In reply to

    • hkraft
    • Not Ranked
    • Joined on 10-13-2006
    • Posts 3
    • Points 45

    Re: Collections in TList

    YES!

    Thanks alot, worked perfectly.

     

    Another question

    I only want to show the tradecodes which has a Ad. It must be possible to create a filter for that, but i cant find any good documentation on how to write my own filter class.

    Ive written a sorter, "public class TradeCodeSort : System.Collections.Generic.IComparer<TradeCode>"

     

    Cheers

     

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