In various database tables I have both a property and a value column. I\'m using Linq to SQL to access the database.
I\'m writing a method which returns a dictionary
This happens because of how Table
is declared:
public sealed class Table : IQueryable,
IQueryProvider, IEnumerable, ITable, IQueryable, IEnumerable,
IListSource
where TEntity : class // <-- T must be a reference type!
The compiler is complaining because your method has no constraints on T
, which means that you could accept a T
which doesn't conform to the specification of Table
.
Thus, your method needs to be at least as strict about what it accepts. Try this instead:
private static Dictionary GetProperties(Table table) where T : class