tags:

views:

27

answers:

1

I have a Data Class called MyTable, and the source property is TABLE (table name in database).

How to retrieve the source property given a Linq<Table>?

DBDataContext db = new DBDataContext();

db.MyTable.GetSource() ??
A: 

The MyTable data class should have a Table attribute on it. You should be able to do something like this:

        var tableType = db.MyTable.GetType().GetGenericArguments().First();
        foreach (TableAttribute attrib in tableType.GetCustomAttributes(false))
        {
            Console.WriteLine(attrib.Name);
        }
BFree
Thanks BFree! -> ((TableAttribute)db.MyTable.GetType().GetGenericArguments().First().GetCustomAttributes(false).First()).Name
Zanoni