Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public IDatabaseTransaction OpenTransaction(IsolationLevel isolation)
 {
     if (_transaction != null)
     {
         throw PtixedException.InvalidTransacionState("open");
     }
     return(new DatabaseTransaction(this, isolation));
 }
Exemplo n.º 3
0
 public void Commit()
 {
     if (_rolledback)
     {
         throw PtixedException.InvalidTransacionState("rolled back");
     }
     if (!_commited)
     {
         _db._transaction.Commit();
     }
     _commited = true;
 }
Exemplo n.º 4
0
        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());
        }