Are there type-safe names of typed lists fields available?

Posts   
 
    
Jurgen
User
Posts: 3
Joined: 12-Jul-2006
# Posted on: 03-Nov-2006 09:19:03   

When I want a type-safe constant that represents the name of an entity field, I can use something like this:

InventoryBookFields.Title.Name

However, I cannot find the equivalent for fields in typed lists. Are there any constants that represent the name of a typed list field?

The reason is that I want to use these constants in the Eval() and Bind() expressions in my GridViews and FormViews. I am now simply using strings like "Title", which are of course not type-safe.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 03-Nov-2006 10:15:57   

In v2, each typedlist has a typedlistfieldindex, defined in the ConstantsEnums. If you're using 1.0.2005.1, you could use this template snippet:

<[ Foreach TypedList CrLf ]> 
    /// <summary>
    /// Index enum to fast-access TypedList Fields in the Columns collection of the Typed List: <[ CurrentTypedListName ]>
    /// </summary>
    public enum <[CurrentTypedListName]>TypedListFieldIndex:int
    {
<[Foreach TypedListField CommaCrLf]>        ///<summary><[TypedListFieldName]></summary>
        <[TypedListFieldName]><[NextForeach]><[If HasFields]>,<[EndIf]>
        /// <summary></summary>
        AmountOfFields
    }
<[ NextForeach ]>
Frans Bouma | Lead developer LLBLGen Pro