DbModelFramework.Sqlite
1.6.3
dotnet add package DbModelFramework.Sqlite --version 1.6.3
NuGet\Install-Package DbModelFramework.Sqlite -Version 1.6.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="DbModelFramework.Sqlite" Version="1.6.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DbModelFramework.Sqlite --version 1.6.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DbModelFramework.Sqlite, 1.6.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 DbModelFramework.Sqlite as a Cake Addin #addin nuget:?package=DbModelFramework.Sqlite&version=1.6.3 // Install DbModelFramework.Sqlite as a Cake Tool #tool nuget:?package=DbModelFramework.Sqlite&version=1.6.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DbModelFramework
Getting started
Environment
Download NuGet-Package
Inject InjectionContainer
As a minimum requirement you have to define a new injection container with at least a DbRequirements class as a part. You can use one of the predifined DbRequirements (DbModelFramework.Sqlite, DbModelFramework.MySql, DbModelFramework.MsSql). The DbRequirements class has to export the type DbModelFramework.DbRequirements.
Your DbRequirements class:
[Export(typeof(DbModelFramework.DbRequirements))]
class DbRequirements : DbModelFramework.Sqlite.DbRequirements
{
private static readonly string ConnectionString = new SqliteConnectionStringBuilder { DataSource = "database.db" }.ConnectionString;
public override IDbConnection CreateDbConnection()
{
var connection = new SqliteConnection(ConnectionString);
connection.Open();
return connection;
}
}
Injection container creation (System.Composition is required):
var configuration = new ContainerConfiguration();
configuration.WithPart<DbRequirements>();
DbModelFramework.DependencyInjection.InjectionContainer = configuration.CreateContainer();
Use the models
Define a new model class
class MyModel : Model<MyModel>
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}
Create a new model instance (insert in db)
var myModel = MyModel.Create();
Get all model data
var myModels = MyModel.Get();
Get all model data which fits in the condition
var myModels = MyModel.Get(model => model.Property1 == "MyValue");
Get model data by primary key
var myModel = MyModel.Get(1); // Get model data with primary key 1
Save changes of a models data (update in db)
myModel.Save();
Delete model data (delete from db)
myModel.Delete();
Reload model data
myModel.Reload();
Advanced
Model-in-Model
class MyReferencedModel : Model<MyReferencedModel>
{
public string Property { get; set; }
}
class MyReferencingModel : Model<MyReferencingModel>
{
public MyReferencedModel ReferencedModel { get; set; }
}
Unique values
class MyUniqueValueModel : Model<MyUniqueValueModel>
{
[Unique]
public string UniqueProperty { get; set; }
}
Ignore values for db storage
class MyDbIgnoreModel : Model<MyDbIgnoreModel>
{
[DbIgnore]
public string NotSavedInDbProperty { get; set; }
public string SavedInDbProperty { get; set; }
}
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
- DbModelFramework (>= 1.6.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.