Infotekka.LightData
3.0.0
See the version list below for details.
dotnet add package Infotekka.LightData --version 3.0.0
NuGet\Install-Package Infotekka.LightData -Version 3.0.0
<PackageReference Include="Infotekka.LightData" Version="3.0.0" />
paket add Infotekka.LightData --version 3.0.0
#r "nuget: Infotekka.LightData, 3.0.0"
// Install Infotekka.LightData as a Cake Addin #addin nuget:?package=Infotekka.LightData&version=3.0.0 // Install Infotekka.LightData as a Cake Tool #tool nuget:?package=Infotekka.LightData&version=3.0.0
Nuget Package Url
https://www.nuget.org/packages/Infotekka.LightData
Introduction
LightData is a asynchronous lightweight SQL based ORM that is designed to be used with data-first applications. It can quickly connect you to your datasource and provide fully functional models to create, read, update, and delete table data, plus execute stored procedures and retrieve results.
Getting Started
While it is possible to write your own models, there is a suggested convention to most effectively use the LightData tools. There is a built-in Model Builder which will generate code based on your database and create C# classes to match.
- Set up a simple C# library project (for example
My.NameSpace.Project.Data
, which your main application will reference. This is to separate the data access from the main application and makes testing easier. - Create a complimentary test project for the new library project.
- Create a test class called
ModelBuilder
. - Add a using directive for both
Infotekka.LightData
andInfotekka.LightData.Schema
. - Create a test called
BuildModels
. - Use the methods in
Infotekka.LightData.ModelBuilder
to generate code models and write them to the filesystem. For example:
string connectionString = "[Your Connection String]"; string nameSpace = "Your.Project.Application.Data"; //This is the namespace that new models will use. string literalConnectionStringProperty = "Runtime.ConnectionString"; //This is literal code that will be inserted into the ConnectionString property on new models, it should reference a class and property available to all models. string path = "../../../../Your.Project.Application.Data"; //A path on the filesystem where the models will be written. This example is relative to the test. var tables = SchemaCore.GetTables(connectionString); foreach (var t in tables) { string classname = t.TableName.CapFirstVariableName(); string fname = $"{path}/{classname}.cs"; if (System.IO.File.Exists(fname)) { System.IO.File.Delete(fname); } Infotekka.CoreData.ModelBuilder.BuildModel(path, t, nameSpace, csStringMap); }
- Create a test class called
- Connect to and use your data. The model builder creates a class for each table, with a subclass that defines the record structure in the table. Access the data by creating an instance of the table class then calling
.Load()
or.LoadAsnyc()
against it. Without paramters.Load()
will load the entire table, however you can pass a simple lambda query in the function. For exampleawait myTable.Load(l => l.FirstName == "James");
.
Contribute
Still working on this part, find us at https://www.infotekka.com for questions and comments.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net48 is compatible. net481 was computed. |
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. |
-
.NETFramework 4.8
- System.Data.SqlClient (>= 4.8.6)
-
.NETStandard 2.1
- Microsoft.Data.SqlClient (>= 5.2.2)
- System.Data.SqlClient (>= 4.8.6)
-
net6.0
- Microsoft.Data.SqlClient (>= 5.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.