/// <summary> /// 获取 <see cref="ViewColumn"/> 元数据序列。 /// </summary> /// <param name="table">架构信息的表。</param> /// <param name="action">用于填充元数据的方法。</param> /// <returns></returns> protected virtual IEnumerable <ViewColumn> GetViewColumns(DataTable table, Action <ViewColumn, DataRow> action) { foreach (DataRow row in table.Rows) { var item = new ViewColumn { Catalog = row["VIEW_CATALOG"].ToString(), Schema = row["VIEW_SCHEMA"].ToString(), ViewName = row["TABLE_NAME"].ToString(), Name = row["COLUMN_NAME"].ToString(), }; if (action != null) { action(item, row); } yield return(item); } }
/// <summary> /// 获取 <see cref="ViewColumn"/> 元数据序列。 /// </summary> /// <param name="table">架构信息的表。</param> /// <param name="action">用于填充元数据的方法。</param> /// <returns></returns> protected override IEnumerable <ViewColumn> GetViewColumns(DataTable table, Action <ViewColumn, DataRow> action) { foreach (DataRow row in table.Rows) { var item = new ViewColumn { Catalog = row["VIEW_CATALOG"].ToString(), Schema = row["VIEW_SCHEMA"].ToString(), ViewName = row["VIEW_NAME"].ToString(), Name = row["COLUMN_NAME"].ToString(), DataType = row["DATA_TYPE"].ToString(), NumericPrecision = row["NUMERIC_PRECISION"].To <int>(), NumericScale = row["NUMERIC_SCALE"].To <int>(), IsNullable = row["IS_NULLABLE"] != DBNull.Value && row["IS_NULLABLE"].To <bool>(), Size = row["CHARACTER_MAXIMUM_LENGTH"].To <long>(), Position = row["ORDINAL_POSITION"].To <int>() }; if (action != null) { action(item, row); } yield return(item); } }