Browse Source

Merge branch 'dev' into ui-notification-service-additional-methods

pull/5711/head
İlkay İlknur 6 years ago
parent
commit
6cc4bcd03f
  1. 12
      docs/en/Entity-Framework-Core-SQLite.md
  2. 21
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EfCoreRepositoryExtensions.cs

12
docs/en/Entity-Framework-Core-SQLite.md

@ -23,6 +23,16 @@ Find `UseSqlServer()` calls in your solution, replace with `UseSqlite()`. Check
SQLite connection strings are different than SQL Server connection strings. So, check all `appsettings.json` files in your solution and replace the connection strings inside them. See the [connectionstrings.com]( https://www.connectionstrings.com/sqlite/ ) for details of SQLite connection string options.
An example connection string is
```
{
"ConnectionStrings": {
"Default": "Filename=./MySQLiteDBFile.sqlite"
}
}
```
You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure.
## Re-Generate the Migrations
@ -38,4 +48,4 @@ Run the `.DbMigrator` project to create the database and seed the initial data.
## Run the Application
It is ready. Just run the application and enjoy coding.
It is ready. Just run the application and enjoy coding.

21
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EfCoreRepositoryExtensions.cs

@ -5,32 +5,29 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
namespace Volo.Abp.Domain.Repositories
{
//TODO: Should work for any IRepository implementation
public static class EfCoreRepositoryExtensions
{
public static DbContext GetDbContext<TEntity, TKey>(this IReadOnlyBasicRepository<TEntity, TKey> repository)
where TEntity : class, IEntity<TKey>
public static DbContext GetDbContext<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity
{
return repository.ToEfCoreRepository().DbContext;
}
public static DbSet<TEntity> GetDbSet<TEntity, TKey>(this IReadOnlyBasicRepository<TEntity, TKey> repository)
where TEntity : class, IEntity<TKey>
public static DbSet<TEntity> GetDbSet<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity
{
return repository.ToEfCoreRepository().DbSet;
}
public static IEfCoreRepository<TEntity, TKey> ToEfCoreRepository<TEntity, TKey>(this IReadOnlyBasicRepository<TEntity, TKey> repository)
where TEntity : class, IEntity<TKey>
public static IEfCoreRepository<TEntity> ToEfCoreRepository<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity
{
var efCoreRepository = repository as IEfCoreRepository<TEntity, TKey>;
if (efCoreRepository == null)
if (repository is IEfCoreRepository<TEntity> efCoreRepository)
{
throw new ArgumentException("Given repository does not implement " + typeof(IEfCoreRepository<TEntity, TKey>).AssemblyQualifiedName, nameof(repository));
return efCoreRepository;
}
return efCoreRepository;
throw new ArgumentException("Given repository does not implement " + typeof(IEfCoreRepository<TEntity>).AssemblyQualifiedName, nameof(repository));
}
}
}

Loading…
Cancel
Save