Determining the column type "MetaColumn, MetaChildrenColumn, MetaForeignKeyColumn"

Last post 05-12-2008 11:47 AM by sjnaughton. 3 replies.

Sort Posts:

  • Determining the column type "MetaColumn, MetaChildrenColumn, MetaForeignKeyColumn"

    05-12-2008, 10:20 AM
    • Loading...
    • sjnaughton
    • Joined on 04-29-2008, 1:11 PM
    • Newton-le-Willows, UK
    • Posts 319

    Determining the column type "MetaColumn, MetaChildrenColumn, MetaForeignKeyColumn"

    1. I'm trying to determine the column type of the column in _table.columns collection
    2. If a column is of the type MetaForeignKeyColumn or MetaChildrenColumn then do not show if the destination table has a custom attribute set to hidden.

    This allow me suppress Insert, Edit, Details links dynamically based on custom attribute information.

    Steve

    Seeking the elegant solution.
    [Oh! If olny I colud tpye!Confused]
    c# Bits blog
  • Re: Determining the column type "MetaColumn, MetaChildrenColumn, MetaForeignKeyColumn"

    05-12-2008, 10:29 AM
    • Loading...
    • sjnaughton
    • Joined on 04-29-2008, 1:11 PM
    • Newton-le-Willows, UK
    • Posts 319

    OK I've sorted 1. out myself:

    if (column.Scaffold && column.GetType() == MetaForeignKeyColumn)
    {
        //TODO: sonthing here
    }  
    This gets me the coulmns I want now I want to determin which table they point to:
    i.e. in Northwind the CustomerId and therefore Customer (column type MetaForeignKeyColumn) points to the Customers Column)
    What I want to know is how to find this information at run time?

     

    Steve

    Seeking the elegant solution.
    [Oh! If olny I colud tpye!Confused]
    c# Bits blog
  • Re: Determining the column type "MetaColumn, MetaChildrenColumn, MetaForeignKeyColumn"

    05-12-2008, 11:27 AM
    Answer
    • Loading...
    • davidebb
    • Joined on 06-11-2002, 8:31 AM
    • Redmond, WA
    • Posts 854
    • AspNetTeam

    Instead of comparing the type, try something like this:

    var fkColumn as MetaForeignKeyColumn;
    if (fkColumn != null) {
        // fkColumn.ParentTable gives you what you want
    }
    David
  • Re: Determining the column type "MetaColumn, MetaChildrenColumn, MetaForeignKeyColumn"

    05-12-2008, 11:47 AM
    • Loading...
    • sjnaughton
    • Joined on 04-29-2008, 1:11 PM
    • Newton-le-Willows, UK
    • Posts 319

    Thanks David,

    I knew there would be a way to traverse the relationships Big Smile

    Steve

    Seeking the elegant solution.
    [Oh! If olny I colud tpye!Confused]
    c# Bits blog
Page 1 of 1 (4 items)