>>>>>>>public class TableSchema >>>>>>>{ >>>>>>> >>>>>>>internal String TableName; >>>>>>> >>>>>>>public List<ColumnSchema> Columns = new List<ColumnSchema>(); >>>>>>> >>>>>>>} >>>>>>>>>>>>>>then how would I retrieve column schema for particular column name ?
var columnSchema = Columns.Where(x => x.ColumnName == "Name").FirstOrDefault();>>>>>
Dictionary<string, ColumnSchema> columnTypes; >>> >>> using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.SchemaOnly)) >>> { >>> >>> columnTypes = (from DataRow r in reader.GetSchemaTable().AsEnumerable() >>> select new ColumnSchema >>> { >>> ColumnName = (string) r["ColumnName"], >>> ColumnSize = (Int32) r["ColumnSize"], >>> DbType = (SqlDbType) r["ProviderType"], >>> DataType = (Type) r["DataType"] >>> }).ToDictionary(cs=> cs.ColumnName); >>> }Fair point. Guess we don't know enough about the context in which the collection will be used. One downside of a Dictionary is that it makes it more difficult to access an item by anything other than the ColumnName?