コード例 #1
0
        public async Task <ImageInfo> InsertImage(ImageInfo imageInfo, Stream image,
                                                  CancellationToken token)
        {
            using (var transaction = _connection.BeginTransaction())
            {
                imageInfo.ImageId = await _largeObjectManager.CreateAsync(imageInfo.ImageId, token);

                using (var stream = await _largeObjectManager.OpenReadWriteAsync(imageInfo.ImageId, token))
                {
                    await image.CopyToAsync(stream);
                }
                imageInfo.Id = _connection.InsertId(imageInfo);
                transaction.Commit();
                return(imageInfo);
            }
        }
コード例 #2
0
 public void DeleteUser(int id)
 {
     using (var dataConnectionTransaction = _hereForYouConnection.BeginTransaction())
     {
         _hereForYouConnection.UserClaims.Where(claim => claim.UserId == id).Delete();
         _hereForYouConnection.UserLogins.Where(login => login.UserId == id).Delete();
         _hereForYouConnection.UserRoles.Where(role => role.UserId == id).Delete();
         _hereForYouConnection.UserTokens.Where(token => token.UserId == id).Delete();
         _hereForYouConnection.Users.Where(user => user.Id == id).Delete();
         dataConnectionTransaction.Commit();
     }
 }