/// <summary> /// Initialize <see cref="LightDataColumn"/> from <see cref="DataColumn"/> /// </summary> /// <param name="column">Source column</param> /// <param name="storage">Existing storage</param> protected override void Initialize(DataColumn column, object storage) { if (Table.RowsCount > 0) { DbNullBits = new BitArray(Table.RowsCount); _values = new Guid[Table.RowsCount]; var store = (object[])ValuesField.GetValue(storage); bool hasNulls = false; for (int i = 0; i < Table.RowsCount; ++i) { if (store[i] != null) { _values[i] = (Guid)store[i]; } else { hasNulls = true; DbNullBits.Set(i, true); } } // memory usage optimization if (!hasNulls) { DbNullBits = null; } } }
/// <summary> /// Initialize <see cref="LightDataColumn"/> from <see cref="DataColumn"/> /// </summary> /// <param name="column">Source column</param> /// <param name="storage">Existing storage</param> protected override void Initialize(DataColumn column, object storage) { if (Table.RowsCount > 0) { Array.Copy((Decimal[])ValuesField.GetValue(storage), _values = new Decimal[Table.RowsCount], Table.RowsCount); } }
/// <summary> /// Initialize <see cref="LightDataColumn"/> from <see cref="DataColumn"/> /// </summary> /// <param name="column">Source column</param> /// <param name="storage">Existing storage</param> protected override void Initialize(DataColumn column, object storage) { if (Table.RowsCount > 0) { _values = new byte[Table.RowsCount][]; var source = (object[])ValuesField.GetValue(storage); for (int i = 0; i < Table.RowsCount; ++i) { _values[i] = (byte[])source[i]; } } }