-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复ConfigureServicesContext.ServiceProvider在服务初始化阶段为空的问题. (#480)
- Loading branch information
Showing
10 changed files
with
100 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<AssemblyTitle>$(PackagePrefix).LiteDB.Core</AssemblyTitle> | ||
<AssemblyName>$(PackagePrefix).LiteDB.Core</AssemblyName> | ||
<PackageId>$(PackagePrefix).LiteDB.Core</PackageId> | ||
<PackageTags>LiteDB</PackageTags> | ||
<PackageReleaseNotes> | ||
</PackageReleaseNotes> | ||
<RootNamespace>EasilyNET.LiteDB.Core</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PackageProjectUrl>https://www.nuget.org/packages/EasilyNET.LiteDB.Core</PackageProjectUrl> | ||
<Description>LiteDB 驱动的服务包,方便使用 LiteDB 数据库.</Description> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LiteDB" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using LiteDB; | ||
|
||
namespace EasilyNET.LiteDB.Core; | ||
|
||
/// <summary> | ||
/// LiteDbContext | ||
/// </summary> | ||
public class LiteDbContext : IDisposable | ||
{ | ||
/// <summary> | ||
/// Database | ||
/// </summary> | ||
private ILiteDatabase Database { get; set; } = default!; | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
{ | ||
if (Database is { } db) | ||
{ | ||
db.Dispose(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取 <see cref="ILiteCollection{TDoc}" />. | ||
/// </summary> | ||
/// <typeparam name="TDoc">实体类型</typeparam> | ||
/// <param name="name">集合名称</param> | ||
/// <returns></returns> | ||
public ILiteCollection<TDoc> GetCollection<TDoc>(string name) where TDoc : class | ||
{ | ||
ArgumentException.ThrowIfNullOrWhiteSpace(name, nameof(name)); | ||
return Database.GetCollection<TDoc>(name); | ||
} | ||
|
||
private static ILiteDatabase GetDatabase(string conn) | ||
{ | ||
ArgumentException.ThrowIfNullOrWhiteSpace(conn, nameof(conn)); | ||
return new LiteDatabase(conn, new()); | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="conn"></param> | ||
/// <returns></returns> | ||
public static T CreateInstance<T>(string conn) where T : LiteDbContext | ||
{ | ||
var t = Activator.CreateInstance<T>(); | ||
t.Database = GetDatabase(conn); | ||
return t; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### EasilyNET.LiteDB.Core | ||
|
||
- 提供 DbContext 类型,为业务层提供分离 | ||
- 提供业务中会使用到的一些数据类型 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters