public static object[] Map(MappingConfig config, Type[] types, ColumnValueSet columns) { int offset = 0; var ret = new object[types.Length]; for (int i = 0; i < types.Length; ++i) { if (config.ScalarTypes.Contains(types[i])) { ret[i] = MapScalar(config, types[i], columns.GetRange(offset, 1)); offset += 1; } else { var table = Table.Get(types[i]); ret[i] = MapModel(config, table, columns.GetRange(offset, table.PhysicalColumns.Length)); offset += table.PhysicalColumns.Length; } } if (offset != columns.Count) { throw PtixedException.InvalidMapping(); } return(ret); }
public IDatabaseTransaction OpenTransaction(IsolationLevel isolation) { if (_transaction != null) { throw PtixedException.InvalidTransacionState("open"); } return(new DatabaseTransaction(this, isolation)); }
public void Commit() { if (_rolledback) { throw PtixedException.InvalidTransacionState("rolled back"); } if (!_commited) { _db._transaction.Commit(); } _commited = true; }
public List <ColumnAttribute> GetColumns(PropertyInfo member) { var equals = member.PropertyType.GetMethod(nameof(Equals), new[] { typeof(object) }); if (equals == null || equals.DeclaringType == typeof(object)) { throw PtixedException.MissingImplementation(member.PropertyType, nameof(Equals)); } return(Table.Get(member.PropertyType) .PhysicalColumns .Select(x => new ColumnAttribute(x.Name) { IsAutoIncrement = x.IsAutoIncrement }) .ToList()); }