LibrameStandard.Extensions.Data
5.20.1810.221
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package LibrameStandard.Extensions.Data --version 5.20.1810.221
NuGet\Install-Package LibrameStandard.Extensions.Data -Version 5.20.1810.221
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="LibrameStandard.Extensions.Data" Version="5.20.1810.221" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LibrameStandard.Extensions.Data --version 5.20.1810.221
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LibrameStandard.Extensions.Data, 5.20.1810.221"
#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 LibrameStandard.Extensions.Data as a Cake Addin
#addin nuget:?package=LibrameStandard.Extensions.Data&version=5.20.1810.221
// Install LibrameStandard.Extensions.Data as a Cake Tool
#tool nuget:?package=LibrameStandard.Extensions.Data&version=5.20.1810.221
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
2 LibrameStandard.Extensions.Data (based EntityFrameworkCore)
Install Extension
PM> Install-Package LibrameStandard.Extensions.Data
Register Extension
// Use DependencyInjection
var services = new ServiceCollection();
// Register LibrameStandard
services.AddLibrameStandard()
.AddData()
.AddDbContext<ITestDbContext, TestDbContext>(options =>
{
options.Connection.DefaultString = "default database connection string";
options.Connection.WriteString = "write database connection string";
options.Connection.WriteSeparation = true;
var migrationsAssembly = "AssemblyName";
options.ConfigureDbContext = builder =>
builder.UseSqlServer(options.Connection.DefaultString,
sql => sql.MigrationsAssembly(migrationsAssembly));
});
// Use Store
services.AddTransient<ITestStore, TestStore>();
// Build ServiceProvider
var serviceProvider = services.BuildServiceProvider();
Test Extension
// DbContext
public interface ITestDbContext : IDbContext
{
DbSet<Category> Categories { get; set; }
DbSet<Article> Articles { get; set; }
}
public class TestDbContext : AbstractDbContext<TestDbContext>, ITestDbContext
{
public DbSet<Category> Categories { get; set; }
public DbSet<Article> Articles { get; set; }
}
// Store
public interface ITestStore
{
IList<Category> GetCategories();
IPagingList<Article> GetArticles();
ITestStore UseDefaultStore();
ITestStore UseWriteStore();
}
public class TestStore : ITestStore
{
private readonly ITestDbContext _dbContext;
public TestStore(ITestDbContext dbContext)
{
_dbContext = dbContext;
}
public IList<Category> GetCategories()
{
return _dbContext.Categories.ToList();
}
public IPagingList<Article> GetArticles()
{
return _dbContext.Articles.AsPagingByIndex(order => order.OrderBy(a => a.Id), 1, 10);
}
public ITestStore UseDefaultStore()
{
_dbContext.TrySwitchConnection(options => options.DefaultString);
return this;
}
public ITestStore UseWriteStore()
{
_dbContext.TrySwitchConnection(options => options.WriteString);
return this;
}
}
// Test
public class UnifiedTests
{
[Fact]
public void UnifiedTest()
{
var store = TestServiceProvider.Current.GetRequiredService<ITestStore>();
var categories = store.GetCategories();
Assert.Empty(categories);
// Use Write Database
categories = store.UseWriteStore().GetCategories();
Assert.NotEmpty(categories);
// Restore
store.UseDefaultStore();
var articles = store.GetArticles();
Assert.Empty(articles);
// Use Write Database
articles = store.UseWriteStore().GetArticles();
Assert.NotEmpty(articles);
// Restore
store.UseDefaultStore();
}
}
Product | Versions 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- LibrameStandard (>= 5.20.1810.221)
- LibrameStandard.Extensions.Data.Abstractions (>= 5.20.1810.221)
- Microsoft.EntityFrameworkCore.Relational (>= 2.1.4)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 2.1.1)
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 |
---|
LibrameStandard.Extensions.Data