Can we dynamically query tables?
I had a bug report today that turned out to be caused by a row in a table having a zero primary key. The code assumed that zero meant a new entity, and got confused.
I wanted to check if any other tables contained a row with a zero primary key, but couldn't work out a neat way to do it. All of our primary keys are named "ID", but not all tables have them (don't ask).
The following code gets a list of all the tables, but I'm not sure if I can then use this to query the data...
Mapping.GetTables() .Where(at => at.RowType.DataMembers .Where(dm => dm.DbType != null) .Any(dm => dm.Name == "ID")) .Select(t => t.TableName.Replace("[", "").Replace("]", ""))
Where do I go from here? Can I even do this?