TinyDal 2.0.0

dotnet add package TinyDal --version 2.0.0
NuGet\Install-Package TinyDal -Version 2.0.0
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="TinyDal" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TinyDal --version 2.0.0
#r "nuget: TinyDal, 2.0.0"
#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 TinyDal as a Cake Addin
#addin nuget:?package=TinyDal&version=2.0.0

// Install TinyDal as a Cake Tool
#tool nuget:?package=TinyDal&version=2.0.0

TinyDal

TinyDal is a lightweight and minimal abstraction over ORMs. It provides a convenient abstraction over it.

Usage:


// for some use cases see also the tests project in the solution

private class MyEntity : MultiTenantEntity
{
	public override long TenantId { get; set; }

	public override bool IsDeleted { get; set; }

	[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
	public override long Id { get; set; }

	public string Name { get; set; }
}

private class MyEntityRepository : EFBaseRepository<MyEntity>
{
	public MyEntityRepository (long? tenantId, DbContext context) : base(tenantId, context)
	{

	}

	public void QueryRaw(string sql)		//custom raw query here if you want
	{
		base.ExecuteRaw(sql);
	}
}

private class MyDataContext : EFBaseDataContext
{
	private DbSet<MyEntity> MyEntities { get; set; }

	public MyEntityRepository MyEntityRepository { get; private set; }

	public MyDataContext(DbContextOptions options,
						 long? tenantId,
						 IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
		: base(options, tenantId, isolationLevel)
	{
		this.MyEntityRepository = new MyEntityRepository(tenantId, this);
	}

	protected override void OnModelCreating(ModelBuilder modelBuilder)
	{
		modelBuilder.Entity<MyEntity>().ToTable("MyEntities");
	}
}

//
// Main
//

private MyDataContext BuildDataContext(string connectionString)
{
	var optionsBuilder = new DbContextOptionsBuilder<MyDataContext>();
	optionsBuilder.UseSqlServer(connectionString);
	return new MyDataContext(optionsBuilder.Options, 1);
}

string connectionString = @"Server=(localdb)\dev;Database=TinyDalTestDb;Integrated security=True;";

using (var dataContext = this.BuildDataContext(connectionString))
{
	dataContext.MyEntityRepository.Insert(new MyEntity
	{
		//Id = 1,
		Name = "Name"
	});

	dataContext.Save();

	dataContext.Commit();
}

Features

Some implemented features:

  • Lightweight abstraction
  • Soft-delete management
  • Multi-tenant entity management

For the feature usage see the test project.

Todos

  • NHibernate implementation
  • Dapper implementation

License

MIT

THIS SOFTWARE IS PROVIDED "AS IS" BY THE OWNER AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OWNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 131 9/3/2023
1.0.2 318 12/6/2021
1.0.1 264 12/6/2021
1.0.0 473 6/7/2020