Giter VIP home page Giter VIP logo

dapper.unitofwork's People

Contributors

petrhaus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dapper.unitofwork's Issues

Simple Example

Hello,

Do you have a simple example, how to implements?

Tks,

Rollback

Hi there, how does rollback occours in your code ?
Lets say i have a table with the following fields:

-Id (Int, Key, Auto Increment)
-Name(Nvarchar, Constraint, Not Null)
-Age(Int, Null)

When i try to insert two people in row like.

using(var uow = repositoryFactory.Create(true)){
    uow.Execute(new AddPersonCommand(PersonInstanceOne));
    uow.Execute(new AddPersonCommand(PersonInstanceOne));
    uow.Commit();
}

The first query executes without any throuble as it should, but after the second query where i try to insert an existing constraint i get the exception but the commit accours for the first query.

My repository's execute method looks like this:

public void Execute(ICommand command){
        if (command.RequiresTransaction && _transaction==null)
            throw new Exception($"Error")

        try{
            command.Execute(_connection, _transaction)
        } Catch(SqlClient.SqlException ex
            Debug.WriteLine($"Error: {ex.Message}")
        }
}

Is it deadlock safe ?

Hi again, last week i've forgot to ask you if there were deadlocks or any other async/sync tests for your async methods within sync methods.

In your example, line 36, you're calling the method MainAsync within a sync method, but i also read that the console's Main method may be an exception to these cases where you can actually call an async method and get fine with it in most cases without causing the application to crash.

MainAsync(args).GetAwaiter().GetResult();

The fact that this code will run synchronously may be a problem in most of the cases, after some reading on "don't block asynchronous code". As it looks, it may be there just for demonstration purposes and no real application at all, but i couldn't avoid to look at the same call in Retry.cs, line 34.

HandleExceptionAsync(retryOptions, ex, retryCount).GetAwaiter().GetResult();

After some reading and research about this method, i've found some warnings like "they're meant to be used by the compiler" and "they may cause deadlock".

All these approaches seems more like a way to unwrap the exceptions being thrown if any. My big question is: Is it safe to use GetAwaiter().GetResult() in this context ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.