Giter Site home page Giter Site logo

gravity00 / simplepersistence Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 1.0 356 KB

Simple Persistence is a set of libraries that help developers to create consistent database models and data access code across multiple applications in a simple way.

License: MIT License

C# 100.00%

simplepersistence's People

Stargazers

 avatar SamZ avatar xuxi avatar João Simões  avatar Alexandre Pires avatar

Watchers

João Simões  avatar Alexandre Pires avatar  avatar

Forkers

smeegoan

simplepersistence's Issues

EFAsyncQueryable.AnyAsync(predicate, ct) not filtering

Both EFAsyncQueryable.AnyAsync(predicate, ct) and EFAsyncQueryable.AnyAsync(predicate) are not filtering the results.

Wrong result:

await _uow.PrepareAsyncQueryable(_uow.Orders.Query()).AnyAsync(e => e.Id == "9900115121623520000000389", ct) // true
SELECT 
    CASE WHEN ( EXISTS (SELECT 
        1 AS [C1]
        FROM [Orders] AS [Extent1]
    )) THEN cast(1 as bit) ELSE cast(0 as bit) END AS [C1]
FROM  ( SELECT 1 AS X ) AS [SingleRowTable1]

Correct result:

await _uow.PrepareAsyncQueryable(_uow.GreenLane.Orders.Query().Where(e => e.Id == "9900115121623520000000389")).AnyAsync(ct) // false
exec sp_executesql N'SELECT 
    CASE WHEN ( EXISTS (SELECT 
        1 AS [C1]
        FROM [Orders] AS [Extent1]
        WHERE [Extent1].[Id] = @p__linq__0
    )) THEN cast(1 as bit) ELSE cast(0 as bit) END AS [C1]
    FROM  ( SELECT 1 AS X ) AS [SingleRowTable1]',N'@p__linq__0 nvarchar(4000)',@p__linq__0=N'9900115121623520000000389'

Thread dead lock on multiple commits

When using the extension method ExecuteAndCommitAsync<T>(IUnitOfWork, Func<Task<T>>), if the commit is invoked inside the lambda, the method wont return, making a possible dead lock.

Example:

return Created(await _uow.ExecuteAndCommitAsync(async () =>
{
    var userIdentity = User.Identity.Name;

    entity.CreatedBy(userIdentity);
    entity.IndustryAgent = industryAgent;
    entity.RetailAgent = retailAgent;
    entity.Pharmacy = pharmacy;
    entity.Product = product;
    entity.Id = Guid.NewGuid();
    entity = await _uow.Orders.AddAsync(entity, ct);

    await _uow.CommitAsync(ct);

    return entity;
}, ct));    //  won't return, possible a dead lock

UoW.ExecuteAndCommitAsync does not keep culture in MVC applications

The extension method ExecuteAndCommitAsync is not keeping the current culture and UI culture in ASP.NET 4.5+ applications, making it hard to use resource files properly.
Example:

public async Task<IHttpActionResult> Post(Order entity, CancellationToken ct){

    var resourceText01 = Resources.SomeResourceText;

    return await _uow.ExecuteAndCommitAsync(async () => {

        var resourceText02 = Resources.SomeResourceText;

        if(resourceText01 != resourceText02)
            throw new Exception(
                string.Format("The resource text does not match: {0} != {1}", resourceText01, resourceText02));

        await Task.Delay(3000, ct);

        return Created(entity);
    });
}

ExecuteAndCommitAsync extensions throw AggregateException

The extension methods ExecuteAndCommitAsync are throwing AggregateExceptions instead of the expected exception when using async/await. Example:

try
{
    await _uow.ExecuteAndCommitAsync(async () =>
    {
        throw new ConcurrencyException();
    }, ct);
}
catch (ConcurrencyException)
{
    // won't be catched here
}
catch (AggregateException e)
{
    // will be catched here
}

Logging support

Logging support to make debugging easier, specially when managing scopes and internal exception

Jetbrain Annotations

Using Jetbrains Annotations (ex: [NotNull], [CanBeNull]) would be a nice addition

UoWExtensions are not generic

The extensions present in the UnitOfWorkExtensions class are not generic. It makes some methods (example: public static Task<T> ExecuteAndCommitAsync<T>(this IUnitOfWork uow, Func<IUnitOfWork, CancellationToken, Task<T>> toExecute)) not very helpful because the lambda must cast the IUnitOfWork object to the expected one.

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.