Hi,

I made use of the dbContext generator to create persistent ignorant base classes. I have tended to get away from using Linq as there is too much overhead, and so I now rely on stored procs to do most of the querying for me by using something like:

List<MyTable> lMyTableItems = myDBContext.Database.SqlQuery<MyTable>("EXEC spMyStoredProc @MYParam", new Sql Parameter { ParameterName = MyParam, DbType = System.Data.DbType.String, Value = "HiThere" }).ToList<MyTable>();

Ths works fine, and I have a nice type safe List to work with, that works with Intellisense and everything. However, now I would like to dynamically add 1 or more dynamic properties to the MyTable class at runtime by looking up some stuff in the db. For instance my MyTable table may be:

ID int PK,
MyColumn varchar(200)

At runtime, I want to look up in the database, and determine 1 or more dyamic properties, such as Dyn1 string, Dyn2 string, Dyn3 string, etc, and then get a list of that returned from the stored procedure. So... it might look like:

//Do code to create dynamic class
CreateDynamicExtendedClass(typeof(MyTable));

List<MyTableExtended> lMyTableItems = myDBContext.Database.SqlQuery<MyTableExtended>("EXEC spMyStoredProc @MYParam", new Sql Parameter { ParameterName = MyParam, DbType = System.Data.DbType.String, Value = "HiThere" }).ToList<MyTableExtended>();

public void CreateDynamicExtendedClass(Type baseType)
{
// Do db lookup and code
}

The first time it runs MyTableExtended might have ID,MyColumn, and Dyn1, and the next time it might have ID,MyColumn,Dyn1,Dyn2

I realize that c# 4 introced System.Dynamic and ExpandoObject, but I have never used these. Whats the best way to do what I am looking to do?

Thanks in advance,

David