Bat.EntityFrameworkCore
7.0.3
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Bat.EntityFrameworkCore --version 7.0.3
NuGet\Install-Package Bat.EntityFrameworkCore -Version 7.0.3
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="Bat.EntityFrameworkCore" Version="7.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bat.EntityFrameworkCore --version 7.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bat.EntityFrameworkCore, 7.0.3"
#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 Bat.EntityFrameworkCore as a Cake Addin #addin nuget:?package=Bat.EntityFrameworkCore&version=7.0.3 // Install Bat.EntityFrameworkCore as a Cake Tool #tool nuget:?package=Bat.EntityFrameworkCore&version=7.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
For use Bat.EntityFrameworkCore just do it :
1- Install Bat.EntityFrameworkCore on your project
2- Register IEFGenericRepo<TEntity> to service container for example :
builder.Services.AddTransient<IEFGenericRepo<User>, EFGenericRepo<User>>();
builder.Services.AddTransient<IEFGenericRepo<Address>, EFGenericRepo<Address>>();
builder.Services.AddScoped<AppUnitOfWork>();
3- Use it in bussiness logic for example :
// Create DbContext
public class AppDbContext : BatDbContext
{
public AppDbContext() { }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.ApplyConfigurationsFromAssembly(typeof(AppUnitOfWork).Assembly);
base.OnModelCreating(builder);
}
public DbSet<User> Users { get; set; }
public DbSet<Address> Addresses { get; set; }
}
// Create UnitOfWork
public class AppUnitOfWork : IBatUnitOfWork
{
private readonly AppDbContext _appDbContext;
private readonly IServiceProvider _serviceProvider;
public AppUnitOfWork(AppDbContext appDbContext, IServiceProvider serviceProvider)
{
_appDbContext = appDbContext;
_serviceProvider = serviceProvider;
}
public EFGenericRepo<User> UserRepo => (EFGenericRepo<User>)_serviceProvider.GetRequiredService<IEFGenericRepo<User>>();
public EFGenericRepo<Address> AddressRepo => (EFGenericRepo<Address>)_serviceProvider.GetRequiredService<IEFGenericRepo<Address>>();
public DatabaseFacade Database { get => _appDbContext.Database; }
public ChangeTracker ChangeTracker { get => _appDbContext.ChangeTracker; }
public EFGenericRepo<T> GetRepository<T>() where T : class, IBaseEntity
=> EFGenericRepo<T>)_serviceProvider.GetRequiredService<IEFGenericRepo<T>>();
public async Task<IEnumerable<T>> ExecuteProcedure<T>(string sqlQuery, params object[] parameter) where T : class
=> await _appDbContext.ExecuteProcedure<T>(sqlQuery, parameter);
public Task<SaveChangeResult> BatSaveChangesAsync(CancellationToken cancellationToken = default)
=> _appDbContext.BatSaveChangesAsync(cancellationToken);
public void Dispose()
{
_appDbContext.Dispose();
GC.SuppressFinalize(this);
}
}
// Use power Off EFGenericRepo
public class UserService : IUserService
{
private readonly AppUnitOfWork _appUow;
public UserService(AppUnitOfWork appUnitOfWork)
{
_appUow = appUnitOfWork;
}
public async Task ExecuteSample()
{
var x0 = await _appUow.GetRepository<User>().AnyAsync();
var x1 = await _appUow.AddressRepo.CountAsync();
var x2 = await _appUow.UserRepo
.Include(x => x.Families)
.Select(x => new GetUserDto { UserId = x.UserId, Name = x.Name, Families = x.Families })
.FirstOrDefaultAsync(x => x.UserId > 1);
var xxx1 = await _appUow.UserRepo
.Where(x => x.UserId > 1).ToListAsync();
var xxx2 = await _appUow.UserRepo
.Include(x => x.Families).ToListAsync();
var xxx3 = await _appUow.UserRepo
.Where(x => x.UserId > 1)
.Include(x => x.Families.Where(x => x.FamilyId > 0))
.ThenInclude(x => x.Addresses)
.OrderByDescending(x => x.UserId)
.ToListAsync();
var xxx4 = await _appUow.UserRepo
.Select(x => new { x.UserId, x.Name }).ToListAsync();
var xxx5 = await _appUow.UserRepo
.Include(x => x.Families)
.Select(x => new { x.UserId, x.Name, x.Families }).ToListAsync();
var xxx6 = await _appUow.UserRepo
.Include(x => x.Families)
.Where(x => x.UserId > 1)
.Select(x => new { x.UserId, x.Name, x.Families }).ToListAsync();
var xxx7 = await _appUow.UserRepo
.Include(x => x.Families)
.ThenInclude(x => x.Addresses)
.OrderByDescending(x => x.UserId)
.Select(x => new { x.UserId, x.Name, x.Families })
.FirstOrDefaultAsync();
var xxx8 = await _appUow.UserRepo.AsNoTracking().FirstOrDefaultAsync(x => x.UserId > 1);
var xxx9 = await _appUow.UserRepo.OrderBy(x => x.UserId).FirstOrDefaultAsync(x => x.UserId > 1);
var xxx10 = await _appUow.UserRepo.Where(x => x.UserId > 1).ToPagingListDetailsAsync(pagingParameter);
var xxx11 = await _appUow.UserRepo.Include(x => x.Families).Where(x => x.UserId > 1).ToPagingListDetailsAsync(pagingParameter);
var xxx12 = await _appUow.UserRepo.Select(x => new { x.UserId, x.Name }).OrderByDescending(x => x.UserId).ToPagingListDetailsAsync(pagingParameter);
var xxx13 = await _appUow.UserRepo.AnyAsync(x => x.UserId > 1);
var xxx14 = await _appUow.UserRepo.Include(x => x.Families).AnyAsync();
var xxx15 = await _appUow.UserRepo.Include(x => x.Families).AnyAsync(x => x.UserId > 1);
var xxx16 = await _appUow.UserRepo.CountAsync();
var xxx17 = await _appUow.UserRepo.Include(x => x.Families).CountAsync();
var xxx18 = await _appUow.UserRepo.Include(x => x.Families).CountAsync(x => x.UserId > 1);
var user0 = await _appUow.UserRepo.FirstOrDefaultAsync(
new QueryFilterWithSelector<User, int>
{
Conditions = x => x.UserId > 0,
ThenIncludeProperties = a => a.Include(a => a.Families).ThenInclude(a => a.Addresses),
Selector = x => x.UserId
});
var user00 = await _appUow.UserRepo.FirstOrDefaultAsync(
new QueryFilterWithSelector<User, string>
{
Conditions = x => x.UserId > 0,
ThenIncludeProperties = a => a.Include(a => a.Families).ThenInclude(a => a.Addresses),
Selector = x => x.Name
});
var user001 = await _appUow.UserRepo.FirstOrDefaultAsync(
new QueryFilter<User>
{
Conditions = x => x.UserId > 1,
ThenIncludeProperties = a => a.Include(a => a.Families).ThenInclude(a => a.Addresses),
});
var user002 = await _appUow.UserRepo.GetPagingAsync(
new QueryFilter<User>
{
Conditions = x => x.UserId > 0,
PagingParameter = new PagingParameter(2, 2),
ThenIncludeProperties = a => a.Include(a => a.Families).ThenInclude(a => a.Addresses)
});
var user003 = await _appUow.UserRepo.GetAsync(
new QueryFilter<User>
{
Conditions = x => x.UserId > 0,
ThenIncludeProperties = a => a.Include(a => a.Families).ThenInclude(a => a.Addresses)
});
var query = "EXEC [Auth].[GetUserMenu] @UserId, @Type";
var userMenu = await _appUow.ExecuteProcedure<MenuModel>(query,
new SqlParameter("@UserId", userId),
new SqlParameter("@Type", RoleType.Online));
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Bat.Core (>= 1.1.8)
- Microsoft.EntityFrameworkCore (>= 3.1.16)
- Microsoft.EntityFrameworkCore.SqlServer (>= 3.1.16)
- Microsoft.EntityFrameworkCore.Tools (>= 3.1.16)
-
net5.0
- Bat.Core (>= 1.1.8)
- Microsoft.EntityFrameworkCore (>= 5.0.13)
- Microsoft.EntityFrameworkCore.SqlServer (>= 5.0.13)
- Microsoft.EntityFrameworkCore.Tools (>= 5.0.13)
-
net6.0
- Bat.Core (>= 6.0.2)
- Microsoft.EntityFrameworkCore (>= 7.0.2)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.2)
- Microsoft.EntityFrameworkCore.Tools (>= 7.0.2)
-
net7.0
- Bat.Core (>= 7.0.3)
- Microsoft.EntityFrameworkCore (>= 7.0.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.3)
- Microsoft.EntityFrameworkCore.Tools (>= 7.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bat.EntityFrameworkCore:
Package | Downloads |
---|---|
Bat.EntityFrameworkCore.Tools
For Contact Me Please Send Mail Or Call To : Tel : +989301919109 Mail : mehrannoruzi@gmail.com |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.1 | 385 | 1/22/2024 |
8.0.0 | 227 | 12/1/2023 |
7.0.3 | 456 | 2/28/2023 |
7.0.2 | 455 | 2/4/2023 |
7.0.0 | 431 | 12/6/2022 |
6.0.22 | 249 | 8/21/2023 |
6.0.21 | 223 | 8/19/2023 |
6.0.1 | 996 | 3/27/2022 |
1.1.3 | 1,222 | 12/26/2021 |
1.1.2 | 770 | 7/12/2021 |
1.1.1 | 755 | 4/14/2021 |
1.1.0 | 759 | 3/26/2021 |
1.0.8 | 687 | 2/7/2021 |
1.0.7 | 640 | 2/4/2021 |
1.0.6 | 684 | 1/30/2021 |
1.0.5 | 494 | 10/27/2020 |
1.0.4 | 1,022 | 10/20/2020 |