0

I'd like to add/remove a column from MetaTable. But table.Column is of type ReadOnlycollection<MetaColumn>.
How can I modify, add or remove a column from the table?
Thank you.

Kamyar
  • 18,639
  • 9
  • 97
  • 171

1 Answers1

1

Have you tried ScaffoldColumn?

[MetadataType(typeof(FooMetadata))]
[TableGroupName("Foo")]
    public partial class Foo 
{ 

        [ScaffoldColumn(true)]
        public string MyNewColumnNotinDBTable
        {
            get
            {
                return "FooBar";
            }
        }
}



 public class FooMetadata
    {
        [ScaffoldColumn(false)]     // hide Id column
        public object Id { get; set; }


        public object Name { get; set; }

        public object MyNewColumnNotinDBTable { get; set; }
    }
Ash Machine
  • 9,601
  • 11
  • 45
  • 52
  • Well, fortunately, I have been able to remove a column from the table. The real deal is about adding a custom column to it. – Kamyar Apr 20 '11 at 03:55
  • So are you trying to "remove" a column (as the question indicates) or "add a custom column" (as your comment indicates)? – Ash Machine Apr 20 '11 at 18:05
  • @Ash Machine: Sorry, forgot to update the title when editing. – Kamyar Apr 23 '11 at 03:57
  • OK. I showed how to remove(Id), I showed you how to "Add" the column(Name). Now, how do you wish to "modify" the column? – Ash Machine May 13 '11 at 15:38
  • I upvoted your answer because of showinf me how to hide a column. Well, I didn't get the "Add Column" part. I want to add a column which is not already in the table's column collection. Something like `datatable1.Columns.Add`. `ScaffoldColumn` allows us to show/hide a column which is already in the column collection of the table. – Kamyar May 14 '11 at 05:53
  • Added example MyNewColumnNotInDBTable – Ash Machine May 16 '11 at 17:36