views:

27

answers:

0

Hi,

I'm trying to get count of records of each table by using the following code. But it doesn't work at all. GetMethod("Count") returns always null. I might do really stupid thing though, I don't know what to do.

var list = new List<TableInfoContainer>
{
    new TableInfoContainer{ObjectSetPropertyName="table1"},
    new TableInfoContainer{ObjectSetPropertyName="table2"},
    new TableInfoContainer{ObjectSetPropertyName="table3"},
};

using (var context = new DBEntities())
{
    list.ForEach(x =>{
        var property = context.GetType().GetProperty(x.ObjectSetPropertyName);
        x.RecordCount = (int)typeof(IQueryable).GetMethod("Count").Invoke(property, null);
    });
}

Aany help would be appreciated!

Thanks, yokyo