yes
Thanks but no success with this command.
Issue resolved. I just called below line after insert.
await UnitOfWorkManager.Current.SaveChangesAsync();
Dear, Please review my sample code. I think to understand better what i want.
when i called sql query to get user count after ef insert within same transaction scope, but result is still zero. How to read uncommitted data before commit.
I will used SP instead of raw query.
public class UserRepository : WTMRepositoryBase<User, long>, IUserRepository {
private readonly IActiveTransactionProvider _transactionProvider;
public UserRepository(
IDbContextProvider<WTMDbContext> dbContextProvider,
IActiveTransactionProvider transactionProvider) :
base(dbContextProvider) {
_transactionProvider = transactionProvider;
}
public void CreateUser(CreateUserInput input) {
var user = new User {
Name = input.Name,
Surname = input.Surname,
EmailAddress = input.EmailAddress,
Password = input.Password
};
Insert(user);
var result = GetUserCount();
// result is zero..
}
private int GetUserCount() {
var command = Connection.CreateCommand();
command.CommandText = "SELECT COUNT(*) FROM Users WITH (NOLOCK)";
//command.Transaction = transaction;
command.Transaction = GetActiveTransaction();
command.CommandType = CommandType.Text;
EnsureConnectionOpen();
var output = Convert.ToInt32(command.ExecuteScalar());
return output;
}
private void EnsureConnectionOpen() {
if (Connection.State != ConnectionState.Open) {
Connection.Open();
}
}
private DbTransaction GetActiveTransaction() {
return (DbTransaction)_transactionProvider.GetActiveTransaction(new ActiveTransactionProviderArgs { { "ContextType", typeof(WTMDbContext) }, { "MultiTenancySide", MultiTenancySide } });
}
}
thanks @alper for your time.
but, i want to reduce more than an half time like 1-3 seconds. currently it's take time to load average 4-6 seconds.
have you any idea about it?
Best Regards,
thanks for your support.
mentioned setting is based on .Net-Core and we are using .Net Framework 4.6 in our application. Please let me know if you have knowledge about it.
Thanks again.