Coder Social home page Coder Social logo

threenine / threenine.data Goto Github PK

View Code? Open in Web Editor NEW
494.0 18.0 111.0 8.93 MB

A Microsoft Entity Framework Core plugin providing Unit of work and repository pattern abstraction layer with common functionality

License: Other

C# 97.31% Shell 2.69%
generic repository-pattern unitofworkpattern threenine

threenine.data's Introduction

Generic Repository Pattern for .NET

NuGet Badge NuGet Downloads Twitter Follow PayPal Documentation Status License: GPL v3

A simple lean & clean generic repository pattern for .NET abstraction layer Entity Framework Core.

Originally inspired by writing my blog post Generic Repository Pattern for .NET, however the project has moved on to develop a reusable unit of work package with dependency injection functionality.

Support This Project

If you have found this project helpful, either as a library that you use or as a learning tool, please consider buying the team a coffee:

Buy Me A Coffee

Installation

The simplest method to install Threenine.Data into your solution/project is to use NuGet:

    nuget Install-Package Threenine.Data

Or via the .NET CLI

    dotnet add package Threenine.Data

Check out Nuget package page for more details.

Bugs & Feature requests

If you want to raise a bug or request a feature, please do so via a Github issue and we will attempt to address it as soon as resources are available to do so.

Documentation

All the documentation of how to use and implement the Threenine.Data : Generic Unit of Work and Repository is available on Read the Docs

Open Source

The source code for the project is free to use.

Free to use NOT free to support

Although this product is free to use and the source code is provided free of charge to learn from, the product itself does not come with free support or warranties of any kind.

If you would like an issue fixed or a feature implemented, then you have two options:

  1. Clone the repository, create an issue completing all the details defined in Issue Template. Implement the code, then submit a Pull Request.

  2. Make a donation or subscribe to our product support plan

threenine.data's People

Contributors

garywoodfine avatar siriak 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

threenine.data's Issues

Implement Split query functionality

          Hey not to pile on, but if you're making changes, what do you think about adding support for AsSplitQuery?

I was thinking it might just be another optional boolean on the method like, and then conditionally tacking it on to the query:

public async Task<T> SingleOrDefaultAsync(....bool asSplitQuery = false) {
    ...
    if (asSplitQuery) query = query.AsSplitQuery();
    ...
}

But I have not had a chance to actually test it. Could always do it later as a non-breaking change too. Just thought I'd mention it.

Thanks again-

Originally posted by @KennethScott in #67 (comment)

Get All Items

Since all the Get() method is marked as obsolete what is the best method to return all of the items from a table? If the scenario is to pull all of the records from a lookup table that may have 30 items or more but not so many that it would require paging it seems awkward to pass in Int32.Max as the size parameter and the have IPaginate object as the result when I'm just looking for a collection of objects.

Provide Sample Applications

Have received a number of email requests to provide sample applications to illustrate how Unit Of Work pattern is used

Icclude issue in .net core 6

Description

When "include" a child table its giving me the error: "The call is ambiguous between the following methods or properties"

Steps to reproduce

Two master table model ; --> "t_User", "t_Role"
One Relation table --> "t_Rel"
"t_Rel" have --> one to one --> "t_User" & "t_Role"
"t_User" & "t_Role" have --> one to many --> t_Rel

image

Expected result

image

Actual result

image

Readonly repository

I think it would be greate to have version of Repository that uses DB in read-only mode.

Delete(T entity) throw an excption

_dbSet.Find(entity); throw the follow exception because expect to receive the primary key as parameter and not the entity

{System.ArgumentException: The key value at position 0 of the call to 'DbSet.Find' was of type 'Category', which does not match the property type of 'int'.
at Microsoft.EntityFrameworkCore.Internal.EntityFinder1.FindTracked(Object[] keyValues, IReadOnlyList1& keyProperties)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder1.Find(Object[] keyValues) at Common.Data.Repository.Repository1.Delete(T entity)
at Common.Data.Service.BaseService`1.Delete(T entity)}

 public void Delete(T entity)
        {
            T existing = _dbSet.Find(entity);
            if (existing != null) _dbSet.Remove(existing);
        }

I wrote this method to retrieve the primary key from the entity

        public int GetKey(T entity)
        {
            var keyName = DbContext.Model.FindEntityType(typeof(T)).FindPrimaryKey().Properties
                .Select(x => x.Name).Single();

            return (int)entity.GetType().GetProperty(keyName).GetValue(entity, null);
        }

Use GetRepository and GetRepositoryAsync at same service throughs an exception

Description

using both in the same method

repository = _unitOfWork.GetRepository<User>();
 repositoryAync = _unitOfWork.GetRepositoryAsync<User>();

throws an exception
System.InvalidCastException: 'Unable to cast object of type 'Threenine.Data.Repository1[User]' to type 'Threenine.Data.IRepositoryAsync1[User]'.'

I think if we keep separate dictionaries in uow for each repo type could fix the issue.

I have a catalog database and a profile database

I have a catalog database and a profile database, how to use your library to perform data manipulation on 2 databases/ is there a possibility to perform a transaction i.e. inserting data in catalog database and profile database.

I have tried to subscribe to your support,

It says Paypal INR Failure.

I look forward to hearing from you soon.

Functionality to get a single Item

The repository functionality needs a method to be able to get a single or default value, similar to SingleOrDefault . Although this can easily be achieved by making use of the Get(predicate).SingleOfDefault it would be great to add some additional functionality
Possibly implementing some kind of selector and predicate functionality

Inconsistent naming in SingleOrDefault vs FirstOrDefault

In Linq, SingleOrDefault only returns an entity if exactly 0 or 1 exists whereas FirstOrDefault returns the first (or null) no matter how many exists.

This can be confusing for new users of this package since the repositories use the SingleOrDefault naming, but actually returns a FirstOrDefault behind the scenes.

Are there any reasoning behind chosing one naming scheme over the other and not keeping it consistent?

GetList Order By

image
I am not sure how to pass parameter for order by.
Can Someone advise me?
Thanks in advance.

simple context

simple class year with nullable DateTime Property and then
I try to read all years but I get exception with this message :
"Expression of type 'System.DateTime' cannot be used for assignment to type 'System.Nullable`1[System.DateTime]'"

private DateTime? _yearId;

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.