private EsentRow RetrieveColumns(EsentCell[] columnArray) { var cells = new EsentRow(); foreach (var column in columnArray) { var columnName = column.ColumnName; var encoding = column.Encoding ?? Columns[column.ColumnName].Encoding; var type = Columns[columnName].ColumnType; var bytes = Api.RetrieveColumn(Database.Session.JetId, JetId, Columns[columnName].JetId); var value = ValueProcessor.FromBytes(type, bytes, encoding); cells.Add(new EsentCell(columnName, value, encoding)); } return(cells); }
public static T Deserialize <T>(EsentRow r) where T : new() { var obj = new T(); var type = typeof(T); var props = type.GetRuntimeProperties(); foreach (var cell in r) { var prop = props.FirstOrDefault(p => p.Name == cell.ColumnName); if (prop == null) { continue; } if (cell.Value?.GetType() == prop.PropertyType) { prop.SetValue(obj, cell.Value); } if (cell.Value?.GetType() == typeof(byte[]) && prop.PropertyType != typeof(byte[])) { prop.SetValue(obj, ValueProcessor.FromBytes(prop.PropertyType, cell.AsByteArray, cell.Encoding)); } } return(obj); }
private void RefreshColumns() { CheckState(); _columns = Api.GetTableColumns(Database.Session.JetId, JetId) .Select(i => new EsentColumn { Table = this, Name = i.Name, JetId = i.Columnid, JetDef = new JET_COLUMNDEF { coltyp = i.Coltyp, cp = i.Cp, cbMax = i.MaxLength, grbit = i.Grbit }, DefaultValue = ValueProcessor.FromBytes(i.Coltyp.ToClr(), i.DefaultValue?.ToArray(), Encoding.UTF8) } ) .ToDictionary(c => c.Name); _columnsValid = true; }