Exemplo n.º 1
0
        public void CreateTable <T>()
        {
            CheckDisposed();

            string sql = _emit.CreateTable <T>();

            _log.Debug(sql);
            _exe.ExecuteNonQuery(sql);
        }
Exemplo n.º 2
0
        public T Create <T>(T entity)
        {
            try
            {
                string sql = _emit.Create(entity);
                _log.Debug(sql);
                _exe.ExecuteNonQuery(sql);

                var pk = _emit.GetPrimaryKeyNeedBinding <T>();
                if (pk != null)
                {
                    string sqlId = _emit.FindIdentity <T>();
                    _log.Debug(sqlId);
                    var        id = _exe.ExecuteScalar(sqlId);
                    IReflector r  = Reflector.Bind(entity);
                    r.SetPropertyValue(pk.PropertyName, TypeCast.ChangeToTypeOrNullableType(id, r.GetPropertyType(pk.PropertyName)));
                }
                return(entity);
            }
            catch (Exception ex)
            {
                throw ex.CreateWrapException <ORMException>();
            }
        }
Exemplo n.º 3
0
 public long ExecuteNonQuery(string sql)
 {
     _exe.ExecuteNonQuery(sql);
     return(_exe.AffectedRows);
 }