AspnetCore.Data 3.1.1

dotnet add package AspnetCore.Data --version 3.1.1
NuGet\Install-Package AspnetCore.Data -Version 3.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspnetCore.Data" Version="3.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspnetCore.Data --version 3.1.1
#r "nuget: AspnetCore.Data, 3.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AspnetCore.Data as a Cake Addin
#addin nuget:?package=AspnetCore.Data&version=3.1.1

// Install AspnetCore.Data as a Cake Tool
#tool nuget:?package=AspnetCore.Data&version=3.1.1

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    //other configurations...

    services.AddScoped<IUnityContainer, UnityContainer>();

    var container = services.BuildServiceProvider().GetService<IUnityContainer>();

    container.RegisterType<ICategoryRepository, CategoryRepository>();
    container.RegisterType<IOrderRepository, OrderRepository>();
    container.RegisterType<ICustomerRepository, CustomerRepository>();

    services.AddScoped<IUnitOfWork>(o => new UnitOfWork<NORTHWNDContext>(container));


}

HomeController.cs

public class BaseController : Controller
{
    public IUnitOfWork _uow;

    public BaseController(IUnitOfWork uow)
    {
        _uow = uow;
    }
}

public class HomeController : BaseController
{
    private IOrderRepository _ordersRepo;
    private ICustomerRepository _custRepo;
    private ICategoryRepository _categRepo;

    public HomeController(IUnitOfWork uow) : base(uow)
    {
        _ordersRepo = uow.Get<IOrderRepository>();
        _custRepo = uow.Get<ICustomerRepository>();
        _categRepo = uow.Get<ICategoryRepository>();
    }
	
	
	public void Demo()
	{
		//add
		_categRepo.Add(new Categories { CategoryName = "test", Description = "none" });

		//get
		var cust = _custRepo.Get(c => c.CustomerId == "ALFKI");

		//update
		cust.Address = "Test address";
		_custRepo.Update(cust);

		//delete
		var categ = _categRepo.Get(c => c.CategoryId == 2);
		_categRepo.Remove(categ);

		_uow.Commit();
	}
	
	
	public void Demo2()
	{
		var categoreis = _categRepo.GetCategories();

		var orders = _ordersRepo.GetOrders();

		var cusomters = _custRepo.GetCustomers();

		var customer = _custRepo.GetCustomer("ALFKI");
	}		
}

Repositories

public interface ICategoryRepository : IDataRepository<Categories>
{
    IEnumerable<Categories> GetCategories();
}
public class CategoryRepository : DataRepository<Categories>, ICategoryRepository
{
    public CategoryRepository(DbContext dbContext) : base(dbContext)
    {
    }

    public IEnumerable<Categories> GetCategories()
    {
        return base.SqlQuery<Categories>("select * from categories").ToList();
    }
}

public interface IOrderRepository : IDataRepository<Orders>
{
    IEnumerable<Orders> GetOrders();
}
public class OrderRepository : DataRepository<Orders>, IOrderRepository
{
    public OrderRepository(DbContext dbContext) : base(dbContext)
    {
    }

    public IEnumerable<Orders> GetOrders()
    {
        return base.SqlQuery<Orders>("select * from Orders").ToList();
    }
}

public interface ICustomerRepository : IDataRepository<Customers>
{
    IEnumerable<Customers> GetCustomers();
    Customers GetCustomer(string customerId);
}
public class CustomerRepository : DataRepository<Customers>, ICustomerRepository
{
    public CustomerRepository(DbContext dbContext) : base(dbContext)
    {
    }

    public Customers GetCustomer(string customerId)
    {
        var (cust,outParams) = base.SqlQuery2<Customers>("spGetCustomersById", true, new { CustomerId = customerId }, new { TotalRows = 0 });

        var count = outParams.Get<int>("TotalRows");

        return cust.FirstOrDefault();
    }

    public IEnumerable<Customers> GetCustomers()
    {
        return base.SqlQuery<Customers>("spGetCustomers",true).ToList();
    }
}	

SQL scripts sample

//
create proc spGetCustomersById
@CustomerId varchar(20),
@TotalRows int out
as
begin
	select * from Customers where CustomerID = @CustomerId
	select @TotalRows = count(1) from Customers where CustomerID = @CustomerId
end

//
create proc spGetCustomers
as
begin
	select * from Customers
end	
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.1 709 7/22/2020
3.1.0 585 2/22/2020
2.2.0 578 3/10/2020
1.0.10 894 11/9/2018
1.0.9 757 10/29/2018
1.0.8 771 10/18/2018
1.0.7 915 8/6/2018
1.0.6 889 8/3/2018
1.0.5 923 7/30/2018
1.0.4 942 7/30/2018
1.0.3 906 7/30/2018
1.0.2 894 7/29/2018